Created a GetAllFormats Stored Procedure for Update Formats

Use new Stored Procedure to get all formats including those designation unused
This commit is contained in:
Rich 2018-05-18 16:05:53 +00:00
parent 588edabb25
commit 11086a17a1
2 changed files with 100 additions and 5 deletions

View File

@ -13849,6 +13849,41 @@ IF (@@Error = 0) PRINT 'Procedure Creation: getFormats Succeeded'
ELSE PRINT 'Procedure Creation: getFormats Error on Creation'
GO
/****** Object: StoredProcedure [getAllFormats] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAllFormats]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [getAllFormats];
GO
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2018 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[getAllFormats]
WITH EXECUTE AS OWNER
AS
SELECT * From (SELECT
[FormatID],
[ParentID],
[Name],
[Description],
[Data],
[GenMac],
[DTS],
[UserID],
[LastChanged],
(SELECT COUNT(*) FROM [Contents] WHERE [Contents].[FormatID]=[Formats].[FormatID]) [ContentCount],
(SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[FormatID]=[Formats].[FormatID]) [DocVersionCount],
(SELECT COUNT(*) FROM [Folders] WHERE [Folders].[FormatID]=[Formats].[FormatID]) [FolderCount],
(SELECT COUNT(*) FROM [Formats] [Children] WHERE [Children].[ParentID]=[Formats].[FormatID]) [ChildCount]
FROM [Formats] ) T1
RETURN
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: getAllFormats Succeeded'
ELSE PRINT 'Procedure Creation: getAllFormats Error on Creation'
GO
-----------------------------------------------------------------------------
/*
---------------------------------------------------------------------------
@ -13874,8 +13909,8 @@ BEGIN TRY -- Try Block
set nocount on
DECLARE @RevDate varchar(255)
DECLARE @RevDescription varchar(255)
set @RevDate = '5/10/2018 2:15 PM'
set @RevDescription = 'Exclude formats that contain (Unused) in their description'
set @RevDate = '5/18/2018 11:00 AM'
set @RevDescription = 'Include Unused formats in Format Update'
Select cast(@RevDate as datetime) RevDate, @RevDescription RevDescription
PRINT 'SQL Code Revision ' + @RevDate + ' - ' + @RevDescription
IF( @@TRANCOUNT > 0 ) COMMIT

View File

@ -22,6 +22,21 @@ using System.Collections.Generic;
namespace VEPROMS.CSLA.Library
{
// B2018-078 Update Formats needs to include unused formats
[Serializable()]
public class CriteriaAllFormats
{
bool _AllFormats;
public bool AllFormats
{
get { return _AllFormats; }
set { _AllFormats = value; }
}
public CriteriaAllFormats(bool allFormats)
{
_AllFormats = allFormats;
}
}
public partial class Format
{
public static Format GetJustFormat(int formatID)
@ -219,7 +234,7 @@ namespace VEPROMS.CSLA.Library
if (_LookupFormats == null)
{
_LookupFormats = new Dictionary<string, int>();
FormatInfoList allFormats = FormatInfoList.Get();
FormatInfoList allFormats = FormatInfoList.GetAll(); // B2018-078 Update Formats needs to include unused formats
foreach (FormatInfo myFormat in allFormats)
{
_LookupFormats.Add(myFormat.Name.ToUpper(), myFormat.FormatID);
@ -303,8 +318,8 @@ namespace VEPROMS.CSLA.Library
{
if (!LookupFormats.ContainsKey(fname.ToUpper()))
{
rec = Format.MakeFormat(parent, fname, nmattr, fmtdata, genmacdata, fmtfi.LastWriteTimeUtc, Userid);
}
rec = Format.MakeFormat(parent, fname, nmattr, fmtdata, genmacdata, fmtfi.LastWriteTimeUtc, Userid);
}
else
{
rec = Format.Get(LookupFormats[fname.ToUpper()]);
@ -535,6 +550,51 @@ namespace VEPROMS.CSLA.Library
}
public partial class FormatInfoList
{
/// <summary>
/// B2018-078 Return a list of all FormatInfo Including Unused.
/// </summary>
public static FormatInfoList GetAll()
{
try
{
FormatInfoList tmp = DataPortal.Fetch<FormatInfoList>(new CriteriaAllFormats(true));
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FormatInfoList.GetAll", ex);
}
}
private void DataPortal_Fetch(CriteriaAllFormats myCrit)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getAllFormats";
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new FormatInfo(dr));
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
}
private static Csla.SortedBindingList<FormatInfo> _SortedFormatInfoList;
public static Csla.SortedBindingList<FormatInfo> SortedFormatInfoList
{