Skip to content

Commit

Permalink
Merge branch 'develop' into feat/CSET-3029
Browse files Browse the repository at this point in the history
  • Loading branch information
LaddieZeigler committed Mar 5, 2025
2 parents b8fbc9b + 2975452 commit 48fa4b9
Show file tree
Hide file tree
Showing 42 changed files with 20,946 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public static void GenerateSpreadSheet(MemoryStream memoryStream, MaturityRespon
{
foreach (var question in subgrouping.Questions)
{
// Skip maturity level 1 questions and questions that have been met.
if (question.Answer == "Y" || question.MaturityLevel == 1 || isUnpardonable(question.DisplayNumber))
// Skip questions that have been met.
if (question.Answer == "Y" || isUnpardonable(question.DisplayNumber))
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void CopyDBAcrossServersTest()
{
string clientCode = "DHS";
string appCode = "CSET";
DbManager manager = new DbManager(new Version("12.3.1.0"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.4.0.0"), clientCode, appCode);
//TODO finish this.
//manager.CopyDBAcrossServers();
}
Expand All @@ -31,7 +31,7 @@ public void CopyDBFromInstallationSource()
//setup a destination file
string clientCode = "DHS";
string appCode = "CSET";
DbManager manager = new DbManager(new Version("12.3.1.0"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.4.0.0"), clientCode, appCode);
//run the same test twice and make sure that the number increment works
string mdf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest.mdf";
string ldf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest_log.ldf";
Expand All @@ -57,7 +57,7 @@ public void TestUpgrade()
//setup a destination file
string clientCode = "Test";
string appCode = "Test";
DbManager manager = new DbManager(new Version("12.3.1.0"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.4.0.0"), clientCode, appCode);

//manager.ForceCloseAndDetach(DbManager.localdb2019_ConnectionString, "TestWeb");
//manager.AttachTest("TestWeb", testdb, testlog);
Expand All @@ -70,7 +70,7 @@ public void TestUpgrade()

manager.SetupDb();

upgrader.UpgradeOnly(new Version("12.3.1.0"), "data source=(localdb)\\inllocaldb2022;initial catalog=TestWeb;persist security info=True;Integrated Security=SSPI;MultipleActiveResultSets=True");
upgrader.UpgradeOnly(new Version("12.4.0.0"), "data source=(localdb)\\inllocaldb2022;initial catalog=TestWeb;persist security info=True;Integrated Security=SSPI;MultipleActiveResultSets=True");


}
Expand All @@ -83,7 +83,7 @@ public void TestSetup()
//setup a destination file
string clientCode = "DHS";
string appCode = "CSET";
DbManager manager = new DbManager(new Version("12.3.1.0"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.4.0.0"), clientCode, appCode);
manager.SetupDb();
}

Expand All @@ -95,7 +95,7 @@ public void CopyDBFromInstallationSourceTest2()
string mdf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest.mdf";
string ldf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest_log.ldf";

DbManager manager = new DbManager(new Version("12.3.1.0"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.4.0.0"), clientCode, appCode);
//run the same test twice and make sure that the number increment works
string conString = "Server=(localdb)\\inllocaldb2022;Integrated Security=true;AttachDbFileName=" + mdf;
using (SqlConnection conn = new SqlConnection(conString))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyVersion>12.3.1.0</AssemblyVersion>
<AssemblyVersion>12.4.0.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
////////////////////////////////
//
// Copyright 2024 Battelle Energy Alliance, LLC
//
//
////////////////////////////////
using System;
using Microsoft.Data.SqlClient;
using System.IO;
namespace UpgradeLibrary.Upgrade
{
internal class ConvertDatabase12400 : ConvertSqlDatabase
{
public ConvertDatabase12400(string path) : base(path)
{
myVersion = new Version("12.4.0.0");
}

/// <summary>
/// Runs the database update script
/// </summary>
/// <param name="conn"></param>F
public override void Execute(SqlConnection conn)
{
try
{
RunFile(Path.Combine(this.applicationPath, "VersionUpgrader", "SQL", "12310_to_12400.sql"), conn);
RunFile(Path.Combine(this.applicationPath, "VersionUpgrader", "SQL", "12310_to_12400_data.sql"), conn);
this.UpgradeToVersionLocalDB(conn, myVersion);
}
catch (Exception e)
{
throw new DatabaseUpgradeException("Error in upgrading database version 12.3.1.0 to 12.4.0.0: " + e.Message);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
Run this script on:
(localdb)\INLLocalDB2022.CSETWeb12310 - This database will be modified
to synchronize it with:
(localdb)\INLLocalDB2022.CSETWeb12400
You are recommended to back up your database before running this script
Script created by SQL Compare version 14.10.9.22680 from Red Gate Software Ltd at 2/19/2025 10:43:13 AM
*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL Serializable
GO
BEGIN TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[usp_getStandardsResultsByCategory]'
GO

-- =============================================
-- Author: hansbk
-- Create date: 8/1/2018
-- Description: Stub needs completed
-- =============================================
ALTER PROCEDURE [dbo].[usp_getStandardsResultsByCategory]
@assessment_id int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
/*
TODO this needs to take into account requirements vs questions
get the question set then for all the questions take the total risk (in this set only)
then calculate the total risk in each question_group_heading(category)
then calculate the actual percentage of the total risk in each category
order by the total
*/
declare @applicationMode nvarchar(50)

exec dbo.GetApplicationModeDefault @assessment_id, @ApplicationMode output


declare @maxRank int
if(@ApplicationMode = 'Questions Based')
begin
IF OBJECT_ID('tempdb..#Temp') IS NOT NULL DROP TABLE #Temp
IF OBJECT_ID('tempdb..#TempAnswered') IS NOT NULL DROP TABLE #TempAnswered

SELECT s.Set_Name, Question_Group_Heading, Question_Group_Heading_Id, isnull(count(c.question_id),0) qc into #temp
FROM Answer_Questions a
join NEW_QUESTION c on a.Question_Or_Requirement_Id=c.Question_Id
join vQuestion_Headings h on c.Heading_Pair_Id=h.heading_pair_Id
join NEW_QUESTION_SETS s on c.Question_Id = s.Question_Id
join AVAILABLE_STANDARDS v on s.Set_Name = v.Set_Name
join NEW_QUESTION_LEVELS l on s.New_Question_Set_Id = l.New_Question_Set_Id
join STANDARD_SELECTION ss on v.Assessment_Id = ss.Assessment_Id
join UNIVERSAL_SAL_LEVEL ul on ss.Selected_Sal_Level = ul.Full_Name_Sal
where a.Assessment_Id = @assessment_id and a.Answer_Text != 'NA' and v.Selected = 1 and v.Assessment_Id = @assessment_id and l.Universal_Sal_Level = ul.Universal_Sal_Level
group by s.Set_Name, Question_Group_Heading, Question_Group_Heading_Id

insert into #temp (Set_Name, Question_Group_Heading, QC)
select a.Set_name,a.Question_Group_Heading, qc=0 from
(select * from (select distinct question_group_heading from #temp) a, (select distinct set_name from #temp) b) a
left join #temp on a.question_group_heading=#temp.question_group_heading and a.set_name = #temp.set_name
where #temp.set_name is null

SELECT s.Set_Name, Question_Group_Heading, Question_Group_Heading_Id, isnull(count(c.question_id),0) qc into #tempAnswered
FROM Answer_Questions a
join NEW_QUESTION c on a.Question_Or_Requirement_Id=c.Question_Id
join vQuestion_Headings h on c.Heading_Pair_Id=h.heading_pair_Id
join NEW_QUESTION_SETS s on c.Question_Id = s.Question_Id
join AVAILABLE_STANDARDS v on s.Set_Name = v.Set_Name
join NEW_QUESTION_LEVELS l on s.New_Question_Set_Id = l.New_Question_Set_Id
join STANDARD_SELECTION ss on v.Assessment_Id = ss.Assessment_Id
join UNIVERSAL_SAL_LEVEL ul on ss.Selected_Sal_Level = ul.Full_Name_Sal
where a.Assessment_Id = @assessment_id and a.Answer_Text in ('Y','A') and v.Selected = 1 and v.Assessment_Id = @assessment_id and l.Universal_Sal_Level = ul.Universal_Sal_Level
group by s.Set_Name, Question_Group_Heading, question_group_Heading_Id

select t.Set_Name,
s.Short_Name,
t.Question_Group_Heading,
t.Question_Group_Heading_Id as [QGH_Id],
isnull(a.qc,0) yaCount,
isnull(t.qc,0) Actualcr,
round(isnull(cast(a.qc as decimal(18,3))/t.qc,0),5) * 100 [prc]
from #temp t left join #tempAnswered a on t.Set_Name = a.Set_Name and t.Question_Group_Heading = a.Question_Group_Heading
join [SETS] s on t.Set_Name = s.Set_Name
order by Question_Group_Heading desc
end
else
begin

IF OBJECT_ID('tempdb..#TempR') IS NOT NULL DROP TABLE #TempR
IF OBJECT_ID('tempdb..#TempRAnswer') IS NOT NULL DROP TABLE #TempRAnswer

SELECT s.set_name, c.standard_category, isnull(count(c.Requirement_Id),0) qc into #tempR
FROM Answer_Requirements a
join NEW_REQUIREMENT c on a.Question_Or_Requirement_Id=c.Requirement_Id
join REQUIREMENT_SETS s on c.Requirement_Id = s.Requirement_Id
join AVAILABLE_STANDARDS v on s.Set_Name = v.Set_Name
where a.Assessment_Id = @assessment_id and v.Assessment_Id = a.Assessment_Id and v.Selected = 1 and a.Answer_Text <> 'NA'
group by s.set_name, standard_category


insert into #tempR (Set_Name,standard_category, QC)
select a.Set_name,a.standard_category, qc=0 from
(select * from (select distinct standard_category from #tempR) a, (select distinct set_name from #tempR) b) a
left join #tempR on a.standard_category=#tempR.standard_category and a.set_name = #tempR.set_name
where #tempR.set_name is null

SELECT s.set_name, c.standard_category, count(c.Requirement_Id) qc into #tempRAnswer
FROM Answer_Requirements a
join NEW_REQUIREMENT c on a.Question_Or_Requirement_Id=c.Requirement_Id
join REQUIREMENT_SETS s on c.Requirement_Id = s.Requirement_Id
join AVAILABLE_STANDARDS v on s.Set_Name = v.Set_Name
where a.Assessment_Id = @assessment_id and v.Assessment_Id = a.Assessment_Id and v.Selected = 1 and a.Answer_Text in ('Y','A')
group by s.set_name, standard_category

select t.Set_Name,
s.Short_Name,
t.standard_category as [question_group_heading],
0 as [QGH_Id],
isnull(a.qc,0) yaCount,
isnull(t.qc,0) Actualcr,
round(isnull(cast(a.qc as decimal(18,3))/t.qc,0),5) * 100 [prc]
from #tempR t
left join #tempRAnswer a on t.Set_Name = a.Set_Name and t.Standard_Category = a.Standard_Category
join [SETS] s on t.Set_Name = s.Set_Name
order by t.standard_category desc

end
END
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
-- This statement writes to the SQL Server Log so SQL Monitor can show this deployment.
IF HAS_PERMS_BY_NAME(N'sys.xp_logevent', N'OBJECT', N'EXECUTE') = 1
BEGIN
DECLARE @databaseName AS nvarchar(2048), @eventMessage AS nvarchar(2048)
SET @databaseName = REPLACE(REPLACE(DB_NAME(), N'\', N'\\'), N'"', N'\"')
SET @eventMessage = N'Redgate SQL Compare: { "deployment": { "description": "Redgate SQL Compare deployed to ' + @databaseName + N'", "database": "' + @databaseName + N'" }}'
EXECUTE sys.xp_logevent 55000, @eventMessage
END
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT 'The database update failed'
END
GO
Loading

0 comments on commit 48fa4b9

Please sign in to comment.