C2017-003: Support SQL Server for storing of Referenced Object data

This commit is contained in:
2020-01-09 15:39:17 +00:00
parent 7fbc9e358d
commit de58331ffb
19 changed files with 5088 additions and 1230 deletions

View File

@@ -15511,8 +15511,8 @@ BEGIN TRY -- Try Block
set nocount on
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '12/13/2019 7:00 AM'
set @RevDescription = 'Procedure number length when adding procedures'
set @RevDate = '01/09/2020 11:00 AM'
set @RevDescription = 'Referenced Object data in sql server'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
IF( @@TRANCOUNT > 0 ) COMMIT

View File

@@ -0,0 +1,828 @@
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
--/**** DBA FUNCTION ****/
--/* The following can be used as a basis for creating the sql RO database for storing of referenced object for PROMS */
--/* Note that the default sql database name will be generated in during conversion as the current PROMS database name suffixed with '_RO'. */
--/* In the script below, the [VE_PROMS_DB_RO] should be replaced with the name that the RO database should be given */
--/* In the script below, the pathname/filename of the physical database should be modified also. */
--USE [master]
--GO
--/****** Object: Database [VEPROMS_DB_RO] Script Date: 7/23/2019 9:42:54 AM ******/
--CREATE DATABASE [VEPROMS_DB_RO]
-- ON PRIMARY
--( NAME = N'VEPROMS_DB_RO', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_2012\MSSQL\DATA\VEPROMS_DB_RO.mdf' , SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
-- LOG ON
--( NAME = N'VEPROMS_DB_RO_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS_2012\MSSQL\DATA\VEPROMS_DB_RO_log.ldf' , SIZE = 2816KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
--GO
--ALTER DATABASE [VEPROMS_DB_RO] SET COMPATIBILITY_LEVEL = 110
--GO
--ALTER DATABASE [VEPROMS_DB_RO] set TRUSTWORTHY ON;
--GO
--USE VEPROMS_DB_RO
--GO
--EXEC dbo.sp_changedbowner @loginame = N'sa', @map = false
--GO
--sp_configure 'show advanced options', 1;
--GO
--RECONFIGURE;
--GO
--sp_configure 'clr enabled', 1;
--GO
--RECONFIGURE;
--GO
--IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
--begin
--EXEC [VEPROMS_DB_RO].[dbo].[sp_fulltext_database] @action = 'enable'
--end
--GO
--USE [VEPROMS_DB_RO]
--GO
--/**** END OF DBA FUNCTION ****/
-- AFTER THE DATABASE IS CREATED, the following should be executed to create the ROALL table & create the sql stored procedures that */
-- are used by PROMS, to migrate and access the ro data.
if db_name() in('master','model','msdn','tempdb')
begin
DECLARE @ErrorMsg varchar(255)
SET @ErrorMsg = 'Don''t add these procedures and functions to ' + db_name()
PRINT '=========================================================================='
PRINT ''
PRINT @ErrorMsg
PRINT ''
PRINT 'You probably want to be in the VEPROMS database'
PRINT ''
PRINT '=========================================================================='
RAISERROR (@ErrorMsg, 20, -1) with log
RETURN
end
print 'Adding procedures and functions to ' + db_name()
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object: StoredProcedure [dbo].[vlnErrorHandler] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vlnErrorHandler]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vlnErrorHandler];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vlnErrorHandler]
(@ExpectedCount int=-1
,@MessageFormat nvarchar(512)=N'Expected RowCount (%d) not met (%d)')
WITH EXECUTE AS OWNER
AS
BEGIN
DECLARE @ErrorMessage NVARCHAR(4000), @ErrorNumber INT, @ErrorSeverity INT, @ErrorState INT, @ErrorProcedure NVARCHAR(126)
, @ErrorLine INT, @RowCount INT;
SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(),@ErrorNumber = ERROR_NUMBER()
, @ErrorLine = ERROR_LINE(), @ErrorProcedure = ERROR_PROCEDURE(), @RowCount = @@RowCount;
IF @ErrorNumber > 0
BEGIN
IF @ErrorProcedure = OBJECT_NAME(@@PROCID) -- If the Procedure is the current procedure just pass the error message
RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState)
ELSE -- Add in the procedure name and line as well as the error number
RAISERROR (N'%s[%d] - (%d) %s', @ErrorSeverity, @ErrorState, @ErrorProcedure, @ErrorLine, @ErrorNumber, @ErrorMessage)
END
ELSE IF @ExpectedCount <> -1 AND @ExpectedCount <> @RowCount
RAISERROR (@MessageFormat, 16, 1, @ExpectedCount, @RowCount)
END
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: vlnErrorHandler Succeeded'
ELSE PRINT 'Procedure Creation: vlnErrorHandler Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[deleteByParid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[deleteByParid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [deleteByParid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[deleteByParid]
(
@ROTable char(8),
@ParentID char(8)
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DELETE ROALL
WHERE [ROTable] = @ROTable and [ParentID] = @ParentID
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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: deleteByParid Succeeded'
ELSE PRINT 'Procedure Creation: deleteByParid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[deleteByRecid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[deleteByRecid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [deleteByRecid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[deleteByRecid]
(
@ROTable char(8),
@RecID char(8)
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DELETE ROALL
WHERE [ROTable] = @ROTable and [RecID] = @RecID
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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: deleteByRecid Succeeded'
ELSE PRINT 'Procedure Creation: deleteByRecid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[deleteByROTable] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[deleteByROTable]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [deleteByROTable];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[deleteByROTable]
(
@ROTable char(8)
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DELETE ROALL
WHERE [ROTable] = @ROTable
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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: deleteByROTable Succeeded'
ELSE PRINT 'Procedure Creation: deleteByROTable Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getChildData] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getChildData]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getChildData];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getChildData]
(
@ROTable char(8),
@ParentID char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT RecID,RecType, isnull(AccPageID, '') AccPageID, Info
FROM [ROALL]
where ROTable = @ROTable and (RecType = 3 or RecType = 5) and ParentID=@ParentID ORDER BY RecID ASC
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getChildData Succeeded'
ELSE PRINT 'Procedure Creation: getChildData Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getCountChildrenOfChildData] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getCountChildrenOfChildData]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getCountChildrenOfChildData];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getCountChildrenOfChildData]
(
@ROTable char(8),
@ParentID char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT R1.ParentID,COUNT(*) AS CNT
FROM ROALL R1 INNER JOIN ROALL R2 ON R1.ParentID = R2.RecID
WHERE (R1.RecType = 3 or R1.RecType = 5) and R1.ROTable = @ROTable and R2.ROTable = @ROTable and R2.ParentID = @ParentID group by R1.ParentID
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getCountChildrenOfChildData Succeeded'
ELSE PRINT 'Procedure Creation: getCountChildrenOfChildData Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getCountRecidByAccid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getCountRecidByAccid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getCountRecidByAccid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getCountRecidByAccid]
(
@ROTable char(8),
@AccPageID char(32)
)
WITH EXECUTE AS OWNER
AS
SELECT COUNT (RecID)
FROM [ROALL]
WHERE [ROTable]=@ROTable AND AccPageID=@AccPageID
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getCountRecidByAccid Succeeded'
ELSE PRINT 'Procedure Creation: getCountRecidByAccid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getCountRecidByAccidNotRecid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getCountRecidByAccidNotRecid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getCountRecidByAccidNotRecid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getCountRecidByAccidNotRecid]
(
@ROTable char(8),
@RecID char(8),
@AccPageID char(32)
)
WITH EXECUTE AS OWNER
AS
SELECT COUNT (RecID)
FROM [ROALL]
WHERE [ROTable]=@ROTable AND AccPageID=@AccPageID AND (NOT RecID = @RecID)
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getCountRecidByAccidNotRecid Succeeded'
ELSE PRINT 'Procedure Creation: getCountRecidByAccidNotRecid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getCountRecidByParid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getCountRecidByParid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getCountRecidByParid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getCountRecidByParid]
(
@ROTable char(8),
@ParentID char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT COUNT (RecID)
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [ParentID]=@ParentID
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getCountRecidByParid Succeeded'
ELSE PRINT 'Procedure Creation: getCountRecidByParid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getCountRectypeByRectype] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getCountRectypeByRectype]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getCountRectypeByRectype];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getCountRectypeByRectype]
(
@ROTable char(8),
@RecType char(32)
)
WITH EXECUTE AS OWNER
AS
SELECT COUNT (RecType)
FROM [ROALL]
WHERE [ROTable]=@ROTable AND RecType=@RecType
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getCountRectypeByRectype Succeeded'
ELSE PRINT 'Procedure Creation: getCountRectypeByRectype Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getGroupAndSubgroups] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getGroupAndSubgroups]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getGroupAndSubgroups];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getGroupAndSubgroups]
(
@ROTable char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT RecID, RecType, ParentID, isnull(AccPageID, '') AccPageID, Info
FROM [ROALL]
WHERE [ROTable]=@ROTable AND (RecType = 3 or RecType = 5) AND ParentID <> '00000002'
ORDER BY ParentID,RecID ASC
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getGroupAndSubgroups Succeeded'
ELSE PRINT 'Procedure Creation: getGroupAndSubgroups Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getInfoByParidRectype] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getInfoByParidRectype]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getInfoByParidRectype];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getInfoByParidRectype]
(
@ROTable char(8),
@ParentID char(8),
@RecType int
)
WITH EXECUTE AS OWNER
AS
SELECT [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [ParentID]=@ParentID AND [RecType]=@RecType
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getInfoByParidRectype Succeeded'
ELSE PRINT 'Procedure Creation: getInfoByParidRectype Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getInfoByRecid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getInfoByRecid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getInfoByRecid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getInfoByRecid]
(
@ROTable char(8),
@RecID char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecID]=@RecID
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getInfoByRecid Succeeded'
ELSE PRINT 'Procedure Creation: getInfoByRecid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getInfoByRecidRectype] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getInfoByRecidRectype]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getInfoByRecidRectype];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getInfoByRecidRectype]
(
@ROTable char(8),
@RecID char(8),
@RecType int
)
WITH EXECUTE AS OWNER
AS
SELECT [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecID]=@RecID AND [RecType]=@RecType
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getInfoByRecidRectype Succeeded'
ELSE PRINT 'Procedure Creation: getInfoByRecidRectype Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getParidAccidInfoByRecid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getParidAccidInfoByRecid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getParidAccidInfoByRecid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getParidAccidInfoByRecid]
(
@ROTable char(8),
@RecId char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT [ParentID], [AccPageID], [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecID]=@RecId
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getParidAccidInfoByRecid Succeeded'
ELSE PRINT 'Procedure Creation: getParidAccidInfoByRecid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getParidAccidInfoByRectypeParid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getParidAccidInfoByRectypeParid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getParidAccidInfoByRectypeParid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getParidAccidInfoByRectypeParid]
(
@ROTable char(8),
@RecType int,
@ParentID char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT [ParentID], [AccPageID], [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecType]=@RecType AND [ParentID]= @ParentID
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getParidAccidInfoByRectypeParid Succeeded'
ELSE PRINT 'Procedure Creation: getParidAccidInfoByRectypeParid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getRecidByRectypeInfo] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getRecidByRectypeInfo]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getRecidByRectypeInfo];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getRecidByRectypeInfo]
(
@ROTable char(8),
@RecType int,
@mstrecid nvarchar(max)
)
WITH EXECUTE AS OWNER
AS
SELECT [RecID]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecType]=@RecType AND Info like @mstrecid
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getRecidByRectypeInfo Succeeded'
ELSE PRINT 'Procedure Creation: getRecidByRectypeInfo Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getRecidInfoByRectype] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getRecidInfoByRectype]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getRecidInfoByRectype];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getRecidInfoByRectype]
(
@ROTable char(8),
@RecType int
)
WITH EXECUTE AS OWNER
AS
SELECT [RecID], [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecType]=@RecType
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getRecidInfoByRectype Succeeded'
ELSE PRINT 'Procedure Creation: getRecidInfoByRectype Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getRecidInfoByRectypeAsc] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getRecidInfoByRectypeAsc]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getRecidInfoByRectypeAsc];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getRecidInfoByRectypeAsc]
(
@ROTable char(8),
@RecType int
)
WITH EXECUTE AS OWNER
AS
SELECT [RecID], [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecType]=@RecType
ORDER BY RecID ASC
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getRecidInfoByRectypeAsc Succeeded'
ELSE PRINT 'Procedure Creation: getRecidInfoByRectypeAsc Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[getRecidInfoByRectypeParidAsc] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getRecidInfoByRectypeParidAsc]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getRecidInfoByRectypeParidAsc];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getRecidInfoByRectypeParidAsc]
(
@ROTable char(8),
@RecType int,
@ParentID char(8)
)
WITH EXECUTE AS OWNER
AS
SELECT [RecID], [Info]
FROM [ROALL]
WHERE [ROTable]=@ROTable AND [RecType]=@RecType AND [ParentID]=@ParentID
ORDER BY RecID ASC
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getRecidInfoByRectypeParidAsc Succeeded'
ELSE PRINT 'Procedure Creation: getRecidInfoByRectypeParidAsc Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[insertAllRectypes] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[insertAllRectypes]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [insertAllRectypes];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[insertAllRectypes]
(
@ROTable char(8),
@RecID char(8),
@RecType int,
@ParentID char(8),
@AccPageID char(32),
@Info nvarchar(max),
@ModDateTime char(14)
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
INSERT INTO [ROALL]
(
ROTable,
RecID,
RecType,
ParentID,
ModDateTime,
AccPageID,
Info
)
VALUES
(
@ROTable,
@RecID,
@RecType,
@ParentID,
@ModDateTime,
@AccPageID,
@Info
)
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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: insertAllRectypes Succeeded'
ELSE PRINT 'Procedure Creation: insertAllRectypes Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[updateInfoAccidByRecid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[updateInfoAccidByRecid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [updateInfoAccidByRecid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[updateInfoAccidByRecid]
(
@ROTable char(8),
@RecID char(8),
@AccPageID char(32),
@Info nvarchar(max),
@ModDateTime char(14)
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
UPDATE [ROALL]
SET
[Info]=@Info,
[ModDateTime]=@ModDateTime,
[AccPageID]=@AccPageID
WHERE [ROTable]=@ROTable AND [RecID]=@RecID
IF @@ROWCOUNT = 0
BEGIN
IF NOT exists(select * from [ROALL] WHERE [ROTable]=@ROTable AND [RecID]=@RecID)
RAISERROR('ROALL record has been deleted by another user', 16, 1)
ELSE
RAISERROR('ROALL has been edited by another user', 16, 1)
END
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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: updateInfoAccidByRecid Succeeded'
ELSE PRINT 'Procedure Creation: updateInfoAccidByRecid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[updateInfoByRecid] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[updateInfoByRecid]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [updateInfoByRecid];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[updateInfoByRecid]
(
@ROTable char(8),
@RecID char(8),
@Info nvarchar(max),
@ModDateTime char(14)
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
UPDATE [ROALL]
SET
[Info]=@Info,
[ModDateTime]=@ModDateTime
WHERE [ROTable]=@ROTable AND [RecID]=@RecID
IF @@ROWCOUNT = 0
BEGIN
IF NOT exists(select * from [ROALL] WHERE [ROTable]=@ROTable AND [RecID]=@RecID)
RAISERROR('ROALL record has been deleted by another user', 16, 1)
ELSE
RAISERROR('ROALL has been edited by another user', 16, 1)
END
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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: updateInfoByRecid Succeeded'
ELSE PRINT 'Procedure Creation: updateInfoByRecid Error on Creation'
GO
/****** Object: StoredProcedure [dbo].[updateInfoByRecidRectype] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[updateInfoByRecidRectype]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [updateInfoByRecidRectype];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[updateInfoByRecidRectype]
(
@ROTable char(8),
@RecID char(8),
@Info nvarchar(max),
@ModDateTime char(14),
@RecType int
)
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
UPDATE [ROALL]
SET
[Info]=@Info,
[ModDateTime]=@ModDateTime
WHERE [ROTable]=@ROTable AND [RecID]=@RecID AND [RecType]=@RecType
IF @@ROWCOUNT = 0
BEGIN
IF NOT exists(select * from [ROALL] WHERE [ROTable]=@ROTable AND [RecID]=@RecID AND [RecType]=@RecType)
RAISERROR('ROALL record has been deleted by another user', 16, 1)
ELSE
RAISERROR('ROALL has been edited by another user', 16, 1)
END
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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: updateInfoByRecidRectype Succeeded'
ELSE PRINT 'Procedure Creation: updateInfoByRecidRectype Error on Creation'
GO
/****** Object: Table [dbo].[ROALL] ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ROALL]') AND type in (N'U'))
DROP TABLE [dbo].[ROALL]
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE TABLE [dbo].[ROALL](
[ROTable] [char](8) NOT NULL,
[RecID] [char](8) NOT NULL,
[RecType] [int] NOT NULL,
[ParentID] [char](8) NOT NULL,
[AccPageID] [char](32) NULL,
[ModDateTime] [char](14) NOT NULL,
[Info] [nvarchar](max) NULL,
CONSTRAINT [PK_ROMASTER] PRIMARY KEY CLUSTERED
(
[ROTable] ASC,
[RecID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
-- Display the status of Table creation
IF (@@Error = 0) PRINT 'Table Creation: ROALL Succeeded'
ELSE PRINT 'Table Creation: DeleteLog ROALL on Creation'
GO

View File

@@ -0,0 +1,58 @@
if db_name() in('master','model','msdn','tempdb')
begin
DECLARE @ErrorMsg varchar(255)
SET @ErrorMsg = 'Don''t add these procedures and functions to ' + db_name()
PRINT '=========================================================================='
PRINT ''
PRINT @ErrorMsg
PRINT ''
PRINT 'You probably want to be in the VEPROMS Referenced Object (RO) database'
PRINT ''
PRINT '=========================================================================='
RAISERROR (@ErrorMsg, 20, -1) with log
RETURN
end
print 'Adding procedures and functions to ' + db_name()
-----------------------------------------------------------------------------
/*
---------------------------------------------------------------------------
| ADD New Code Before this Block |
| Change Date and Description |
---------------------------------------------------------------------------
*/
-----------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_GetSQLCodeRevision]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vesp_GetSQLCodeRevision];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2019 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_GetSQLCodeRevision]
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
-- Change information in the next line when you are done
set nocount on
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '01/09/2020 11:00 AM'
set @RevDescription = 'Initial Version'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
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 'StoredProcedure [vesp_GetSQLCodeRevision] Succeeded'
ELSE PRINT 'StoredProcedure [vesp_GetSQLCodeRevision] Error on Creation'
go
vesp_GetSQLCodeRevision

View File

@@ -32,6 +32,9 @@ namespace VEPROMS
this.ppBtnOk = new System.Windows.Forms.Button();
this.ppBtnCancel = new System.Windows.Forms.Button();
this.ppPnlRODb = new DevComponents.DotNetBar.PanelEx();
this.ppBtnTestSQL = new System.Windows.Forms.Button();
this.ppTxtSQL = new System.Windows.Forms.TextBox();
this.ppLblSQL = new System.Windows.Forms.Label();
this.ppTxtExt = new System.Windows.Forms.TextBox();
this.ppTxtPath = new System.Windows.Forms.TextBox();
this.ppLblGraphicFileExtLoc = new System.Windows.Forms.Label();
@@ -71,6 +74,9 @@ namespace VEPROMS
//
this.ppPnlRODb.CanvasColor = System.Drawing.SystemColors.Control;
this.ppPnlRODb.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
this.ppPnlRODb.Controls.Add(this.ppBtnTestSQL);
this.ppPnlRODb.Controls.Add(this.ppTxtSQL);
this.ppPnlRODb.Controls.Add(this.ppLblSQL);
this.ppPnlRODb.Controls.Add(this.ppTxtExt);
this.ppPnlRODb.Controls.Add(this.ppTxtPath);
this.ppPnlRODb.Controls.Add(this.ppLblGraphicFileExtLoc);
@@ -92,6 +98,33 @@ namespace VEPROMS
this.ppPnlRODb.Style.GradientAngle = 90;
this.ppPnlRODb.TabIndex = 3;
//
// ppBtnTestSQL
//
this.ppBtnTestSQL.Location = new System.Drawing.Point(542, 110);
this.ppBtnTestSQL.Name = "ppBtnTestSQL";
this.ppBtnTestSQL.Size = new System.Drawing.Size(82, 46);
this.ppBtnTestSQL.TabIndex = 44;
this.ppBtnTestSQL.Text = "Test Connect";
this.ppBtnTestSQL.UseVisualStyleBackColor = true;
this.ppBtnTestSQL.Click += new System.EventHandler(this.ppBtnTestSQL_Click);
//
// ppTxtSQL
//
this.ppTxtSQL.Location = new System.Drawing.Point(129, 156);
this.ppTxtSQL.Name = "ppTxtSQL";
this.ppTxtSQL.Size = new System.Drawing.Size(507, 22);
this.ppTxtSQL.TabIndex = 43;
this.ppTxtSQL.TextChanged += new System.EventHandler(this.ppTxtSQL_TextChanged);
//
// ppLblSQL
//
this.ppLblSQL.AutoSize = true;
this.ppLblSQL.Location = new System.Drawing.Point(30, 156);
this.ppLblSQL.Name = "ppLblSQL";
this.ppLblSQL.Size = new System.Drawing.Size(92, 17);
this.ppLblSQL.TabIndex = 42;
this.ppLblSQL.Text = "SQL Connect";
//
// ppTxtExt
//
this.ppTxtExt.Enabled = false;
@@ -203,5 +236,8 @@ namespace VEPROMS
private System.Windows.Forms.Label ppLblExt;
private System.Windows.Forms.TextBox ppTxtPath;
private System.Windows.Forms.TextBox ppTxtExt;
private System.Windows.Forms.Button ppBtnTestSQL;
private System.Windows.Forms.TextBox ppTxtSQL;
private System.Windows.Forms.Label ppLblSQL;
}
}

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
@@ -58,6 +59,7 @@ namespace VEPROMS
private RODbInfo _roDbInfo;
private string _origROName;
private string _origFolderPath;
private string _origSQLConnect = null;
private DocVersion _docVersion;
public frmRODbProperties(DocVersion docVersion, RODbInfo roDbInfo)
{
@@ -66,6 +68,7 @@ namespace VEPROMS
InitializeComponent();
_origROName = (_roDbInfo == null) ? null : _roDbInfo.ROName;
_origFolderPath = (_roDbInfo == null) ? null : _roDbInfo.FolderPath;
_origSQLConnect = (_roDbInfo == null) ? null : (_roDbInfo.DBConnectionString == null || _roDbInfo.DBConnectionString == "" || _roDbInfo.DBConnectionString == "cstring") ? null : _roDbInfo.DBConnectionString;
// Disable the OK button when initialized. Enable it if the user makes changes
ppBtnOk.Enabled = false;
}
@@ -86,7 +89,8 @@ namespace VEPROMS
// check for modify. If the path to this rodb already exists, we've got to use that
// as the assocation. if it's a new path, i.e. a modify of the rodb record, just save current data.
// Then close & return.
if (_origROName !=null && _origFolderPath !=null && (_origROName != ppRTxtName.Text || _origFolderPath != ppTxtPath.Text))
if ((_origROName !=null && _origFolderPath !=null && (_origROName != ppRTxtName.Text || _origFolderPath != ppTxtPath.Text)) ||
(_origSQLConnect != ppTxtSQL.Text || _origSQLConnect != ppTxtSQL.Text))
{
if (!Directory.Exists(ppTxtPath.Text))
{
@@ -100,6 +104,12 @@ namespace VEPROMS
}
RODb roDb = RODb.GetJustRoDb(_roDbInfo.RODbID);
if (_origROName != ppRTxtName.Text) roDb.ROName = ppRTxtName.Text;
if (!(_origSQLConnect == "cstring" && (ppTxtSQL.Text == null || ppTxtSQL.Text == "")) && _origSQLConnect != ppTxtSQL.Text)
{
// C2017-003: ro in sql. 'cstring' in connection string represents using MS Access database
// if connect string is null, set connect string to "cstring" otherwise, use what user typed in:
roDb.DBConnectionString = (ppTxtSQL.Text == null || ppTxtSQL.Text == "") ? "cstring" : ppTxtSQL.Text;
}
if (_origFolderPath != ppTxtPath.Text)
{
// see if an rodb already exists with this pathname.
@@ -184,7 +194,8 @@ namespace VEPROMS
MessageBox.Show("No existing ro.fst in path " + ppTxtPath.Text + ". Check for invalid path");
return;
}
RODb newroDb = RODb.MakeRODb(ppRTxtName.Text, ppTxtPath.Text, "cstring", null);
string connectstr = ppTxtSQL.Text != null && ppTxtSQL.Text != "" ? ppTxtExt.Text : "cstring";
RODb newroDb = RODb.MakeRODb(ppRTxtName.Text, ppTxtPath.Text, connectstr, null);
RODbInfo newrdi = RODbInfo.Get(newroDb.RODbID);
newroDb.Save().Dispose();
ROFst rofst = ROFstInfo.AddRoFst(newrdi, _docVersion, DoProgressBarRefresh);
@@ -196,6 +207,7 @@ namespace VEPROMS
Location = ParentLocation;
ppRTxtName.Text = (_roDbInfo == null) ? null : _roDbInfo.ROName;
ppTxtPath.Text = (_roDbInfo == null) ? null : _roDbInfo.FolderPath;
ppTxtSQL.Text = (_roDbInfo == null) ? null : (_roDbInfo.DBConnectionString == "cstring") ? null : _roDbInfo.DBConnectionString;
RODbConfig cfg = (_roDbInfo == null) ? new RODbConfig() : new RODbConfig(_roDbInfo);
// Note that the Graphic Extension data is shown in a non-editable text box here because
// the data is either retrieved from the roapp.ini - and if there can only be editted from
@@ -235,5 +247,38 @@ namespace VEPROMS
//The OK button should only be enabled if the path has changed
ppBtnOk.Enabled = _origFolderPath != ppTxtPath.Text;
}
private void ppTxtSQL_TextChanged(object sender, EventArgs e)
{
//The OK button should only be enabled if the path has changed
ppBtnOk.Enabled = _origSQLConnect != ppTxtSQL.Text;
}
// C2017-003: test that the sql string entered can connect to the database:
private void ppBtnTestSQL_Click(object sender, EventArgs e)
{
try
{
using (SqlConnection connection = new SqlConnection(ppTxtSQL.Text))
{
try
{
connection.Open();
if (connection.State == ConnectionState.Open)
{
MessageBox.Show("You have been successfully connected to the database!");
}
else
{
MessageBox.Show("Connection failed.");
}
}
catch (SqlException) { }
}
}
catch (Exception ex)
{
MessageBox.Show("Connection failed: " + ex);
}
}
}
}

View File

@@ -98,6 +98,7 @@ namespace VEPROMS
this.tcpGeneral = new DevComponents.DotNetBar.TabControlPanel();
this.tiGeneral = new DevComponents.DotNetBar.TabItem(this.components);
this.tcpRefereceObjects = new DevComponents.DotNetBar.TabControlPanel();
this.ppBtnRoToSql = new System.Windows.Forms.Button();
this.tbRoDb = new System.Windows.Forms.TextBox();
this.ppBtnRoDbBrowse = new System.Windows.Forms.Button();
this.btnRoDbProperties = new DevComponents.DotNetBar.ButtonX();
@@ -1161,6 +1162,7 @@ namespace VEPROMS
//
// tcpRefereceObjects
//
this.tcpRefereceObjects.Controls.Add(this.ppBtnRoToSql);
this.tcpRefereceObjects.Controls.Add(this.tbRoDb);
this.tcpRefereceObjects.Controls.Add(this.ppBtnRoDbBrowse);
this.tcpRefereceObjects.Controls.Add(this.btnRoDbProperties);
@@ -1185,6 +1187,17 @@ namespace VEPROMS
this.tcpRefereceObjects.TabItem = this.tiRefObjs;
this.tcpRefereceObjects.Enter += new System.EventHandler(this.tabpage_Enter);
//
// ppBtnRoToSql
//
this.ppBtnRoToSql.Location = new System.Drawing.Point(337, 146);
this.ppBtnRoToSql.Name = "ppBtnRoToSql";
this.ppBtnRoToSql.Size = new System.Drawing.Size(163, 46);
this.ppBtnRoToSql.TabIndex = 48;
this.ppBtnRoToSql.Text = "Migrate Data to Sql";
this.ppBtnRoToSql.UseVisualStyleBackColor = true;
this.ppBtnRoToSql.Visible = false;
this.ppBtnRoToSql.Click += new System.EventHandler(this.ppBtnRoToSql_Click);
//
// tbRoDb
//
this.tbRoDb.Enabled = false;
@@ -2903,6 +2916,7 @@ namespace VEPROMS
private DevComponents.DotNetBar.Controls.ComboBoxEx ppCmbxMOSfontName;
private DevComponents.DotNetBar.ButtonX btnMergedOutputSettngs;
private DevComponents.DotNetBar.Controls.CheckBoxX ppChbxMOSview;
private System.Windows.Forms.Button ppBtnRoToSql;
private System.Windows.Forms.CheckBox ppChbxEnhancedAllowMods;
}
}

View File

@@ -318,6 +318,8 @@ namespace VEPROMS
{
RODbInfo rdi = RODbInfo.GetJustRODB(SelectedROFst.RODbID);
tbRoDb.Text = string.Format("{0} ({1})", rdi.ROName, rdi.FolderPath);
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(rdi); // C2017-003: make button visible if ro migration is doable
_CurRoDbInfo = rdi;
}
else
{
@@ -328,7 +330,12 @@ namespace VEPROMS
foreach (RODbInfo rdi in RODbInfoList.Get())
{
int i = cmbRoDb.Items.Add(string.Format("{0} ({1})", rdi.ROName, rdi.FolderPath));
if (rdi.RODbID == myrodbid) selindx = i;
if (rdi.RODbID == myrodbid)
{
selindx = i;
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(rdi); // C2017-003: make button visible if ro migration is doable
_CurRoDbInfo = rdi;
}
}
if (cmbRoDb.Items.Count > 0) cmbRoDb.SelectedIndex = selindx;
}
@@ -1314,7 +1321,7 @@ namespace VEPROMS
// KBR & it was decided that we'd wait to see if users end up needing this. It can be done by going
// into the sql database and modify/delete records if needed.
}
private RODbInfo _CurRoDbInfo = null;
private void cmbRoDb_SelectedIndexChanged(object sender, EventArgs e)
{
// The only way that a selected index can change on the rodb combo box is if there was no rofst
@@ -1337,7 +1344,9 @@ namespace VEPROMS
cmbRoDb.Visible = ppBtnRoDbBrowse.Visible = false;
tbRoDb.Visible = btnRoDbProperties.Visible = true;
tbRoDb.Text = string.Format("{0} ({1})", fst.MyRODb.ROName, fst.MyRODb.FolderPath);
// C2017-003: See if the selected ro databasew has been converted to sql and if not, make visible a button to convert the data.
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(fst.MyRODb);
_CurRoDbInfo = fst.MyRODb;
}
else
{
@@ -1359,7 +1368,31 @@ namespace VEPROMS
cmbRoDb.Visible = ppBtnRoDbBrowse.Visible = false;
tbRoDb.Visible = btnRoDbProperties.Visible = true;
tbRoDb.Text = string.Format("{0} ({1})", tmp.MyRODb.ROName, tmp.MyRODb.FolderPath);
// C2017-003: See if the selected ro database has been converted to sql and if not, make visible a button to convert the data.
RODbInfo rodbi = RODbInfo.GetJustRODB(tmp.MyRODb.RODbID);
ppBtnRoToSql.Visible = ppBtnRoToSql.Enabled = CanMigrateRoAccessToSql(rodbi);
_CurRoDbInfo = rodbi;
}
}
private bool CanMigrateRoAccessToSql(RODbInfo rODbi)
{
// C2017-003: This method is used to determine whether RO data can be migrated from MS Access to sql server
// A command line argument 'RoInSql'. For now, this argument must be used to allow code to run for ro->sql. Later
// this will be changed so that if arugment is used, the program does NOT include button.
if (!Volian.Base.Library.VlnSettings.GetCommandFlag("RoInSql")) return false;
// The following conditions must be true in order to migrate the ro data to sql. Only the first condition can be
// tested in this executable since the roall database is interfaced to by the roeditor & the program that migrates the data.
// The migration program will make the 2-4 tests, put up a message box if it cannot migrate & will send a failure back
// to this program, PROMS.
// 1) the user must be an admin and the rodb record's connection string must be 'cstring' (it is the connection string if data was migrated)
// 2) the roall database must exist when using the rodb record's connection string and this database must have the stored procedures
// 3) roall must be empty
// 4) the database must be the correct version
UserInfo ui = UserInfo.GetByUserID(VlnSettings.UserID);
if (!ui.IsAdministrator()) return false;
return (rODbi.DBConnectionString == "cstring");
}
private void ppBtnRoDbBrowse_Click(object sender, EventArgs e)
@@ -1700,6 +1733,50 @@ namespace VEPROMS
}
}
// C2017-003: The button to migrate ro data from MS Access to sql server was clicked:
private void ppBtnRoToSql_Click(object sender, EventArgs e)
{
string exelocation = Application.ExecutablePath;
try
{
Application.DoEvents();
exelocation = exelocation.Substring(0, exelocation.LastIndexOf("\\")) + @"\RoAccessToSql.exe";
int indx = tbRoDb.Text.IndexOf(" (")+2;
string accesspath = tbRoDb.Text.Substring(indx, tbRoDb.Text.Length - indx - 1);
string sqldb = Database.ActiveDatabase;
indx = Database.DBServer.IndexOf(" ");
string server = Database.DBServer.Substring(0, indx);
string args = @"/acc=" + accesspath + @" /sqldb=" + sqldb + @" /server=" + server;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(exelocation, args);
p.WaitForExit(); // without arguments, this will wait indefinitely
Application.DoEvents();
string _TmpFileForConnectStr = Path.GetTempPath();
_TmpFileForConnectStr = _TmpFileForConnectStr + @"\PromsConnect.txt";
if (File.Exists(_TmpFileForConnectStr)) // if conversion was done, the connection string will be added to the promsconnect.txt file
{
string constring = File.ReadAllText(_TmpFileForConnectStr);
if (constring != null && constring != "" && constring.ToUpper().Contains("DATA SOURCE"))
{
// read in the connection string & set for this rodbinfo
using (RODb rodbtmp = RODb.GetJustRoDb(_CurRoDbInfo.RODbID))
{
rodbtmp.DBConnectionString = File.ReadAllText(_TmpFileForConnectStr);
rodbtmp.Save();
}
// to be sure all aspects of program are using the converted database, tell user to restart:
MessageBox.Show(this, "Restart PROMS to have referenced object database migration take effect.", "", MessageBoxButtons.OK);
}
ppBtnRoToSql.Visible = false;
}
}
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
string tmpmsg = ex.Message;
MessageBox.Show(tmpmsg, "Migration Error: " + ex.GetType().Name);
}
}
}
[XmlRoot("Enhanced")]