Added getDRoUsagesByROIDsAndVersions and getRoUsagesByROIDsAndVersions to speed-up RO Value Update process.
Added logic to speed up RO Value Update Process. Added logic to keep SvgImages from failing if the ImagePath is null.
This commit is contained in:
parent
f36317757d
commit
4994f19997
@ -7062,6 +7062,95 @@ IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_GetVersionFormatItems Succe
|
||||
ELSE PRINT 'TableFunction Creation: vefn_GetVersionFormatItems Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getDRoUsagesByROIDsAndVersions]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getDRoUsagesByROIDsAndVersions];
|
||||
GO
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2012 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
CREATE PROCEDURE [dbo].[getDRoUsagesByROIDsAndVersions]
|
||||
(
|
||||
@ROIDs nvarchar(MAX),
|
||||
@Versions nvarchar(MAX)
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[DROUsages].[DROUsageID],
|
||||
[DROUsages].[DocID],
|
||||
[DROUsages].[ROID],
|
||||
[DROUsages].[Config],
|
||||
[DROUsages].[DTS],
|
||||
[DROUsages].[UserID],
|
||||
[DROUsages].[LastChanged],
|
||||
[DROUsages].[RODbID],
|
||||
[Documents].[LibTitle] [Document_LibTitle],
|
||||
[Documents].[DocContent] [Document_DocContent],
|
||||
[Documents].[DocAscii] [Document_DocAscii],
|
||||
[Documents].[Config] [Document_Config],
|
||||
[Documents].[DTS] [Document_DTS],
|
||||
[Documents].[UserID] [Document_UserID],
|
||||
[Documents].[FileExtension] [Document_FileExtension]
|
||||
FROM [DRoUsages]
|
||||
JOIN vefn_SplitROSearch(@ROIDs) SS
|
||||
ON [DRoUsages].RODBID = SS.[RODBID] and [DRoUsages].[ROID] like SS.[ROID] + '%'
|
||||
JOIN [Documents] ON
|
||||
[Documents].[DocID]=[DROUsages].[DocID]
|
||||
Where [Documents].[DocID] in
|
||||
(Select Distinct [DocID] from [ENTRIES]
|
||||
JOIN [VEFN_GetVersionItems](@Versions) VV ON [Entries].ContentID = VV.ContentID)
|
||||
RETURN
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getDRoUsagesByROIDsAndVersions Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getDRoUsagesByROIDsAndVersions Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getRoUsagesByROIDsAndVersions]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [getRoUsagesByROIDsAndVersions];
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[getRoUsagesByROIDsAndVersions]
|
||||
(
|
||||
@ROIDs nvarchar(MAX),
|
||||
@Versions nvarchar(MAX)
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
SELECT
|
||||
[RoUsages].[ROUsageID],
|
||||
[RoUsages].[ContentID],
|
||||
[RoUsages].[ROID],
|
||||
[RoUsages].[Config],
|
||||
[RoUsages].[DTS],
|
||||
[RoUsages].[UserID],
|
||||
[RoUsages].[LastChanged],
|
||||
[RoUsages].[RODbID],
|
||||
[Contents].[Number] [Content_Number],
|
||||
[Contents].[Text] [Content_Text],
|
||||
[Contents].[Type] [Content_Type],
|
||||
[Contents].[FormatID] [Content_FormatID],
|
||||
[Contents].[Config] [Content_Config],
|
||||
[Contents].[DTS] [Content_DTS],
|
||||
[Contents].[UserID] [Content_UserID]
|
||||
FROM [RoUsages]
|
||||
JOIN vefn_SplitROSearch(@ROIDs) SS
|
||||
ON [RoUsages].RODBID = SS.[RODBID] and [RoUsages].[ROID] like SS.[ROID] + '%'
|
||||
JOIN [Contents] ON
|
||||
[Contents].[ContentID]=[RoUsages].[ContentID]
|
||||
JOIN [VEFN_GetVersionItems](@Versions) VV ON [Contents].ContentID = VV.ContentID
|
||||
RETURN
|
||||
GO
|
||||
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: getRoUsagesByROIDsAndVersions Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: getRoUsagesByROIDsAndVersions Error on Creation'
|
||||
GO
|
||||
|
||||
|
||||
-- =========================================== End of Functions and Procedures
|
||||
|
||||
-- Turn off Auto Close and Auto Shrink
|
||||
declare @CMD varchar(max)
|
||||
set @CMD = 'ALTER DATABASE [' + db_name() +'] SET AUTO_CLOSE OFF'
|
||||
|
@ -175,5 +175,72 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
[Serializable()]
|
||||
private class GetDROUsagesByROIDsAndVersionsCriteria
|
||||
{
|
||||
public GetDROUsagesByROIDsAndVersionsCriteria(string roids,string versions)
|
||||
{
|
||||
_ROIDs = roids;
|
||||
_Versions = versions;
|
||||
}
|
||||
private string _ROIDs;
|
||||
public string ROIDs
|
||||
{
|
||||
get { return _ROIDs; }
|
||||
set { _ROIDs = value; }
|
||||
}
|
||||
private string _Versions;
|
||||
public string Versions
|
||||
{
|
||||
get { return _Versions; }
|
||||
set { _Versions = value; }
|
||||
}
|
||||
}
|
||||
public static DROUsageInfoList GetDROUsagesByROIDsAndVersions(string roids,string versions)
|
||||
{
|
||||
try
|
||||
{
|
||||
DROUsageInfoList tmp = DataPortal.Fetch<DROUsageInfoList>(new GetDROUsagesByROIDsAndVersionsCriteria(roids,versions));
|
||||
DROUsageInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on DROUsageInfoList.GetDROUsagesByROIDsAndVersions", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetDROUsagesByROIDsAndVersionsCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfoList.DataPortal_FetchByROIDsAndVersions", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getDRoUsagesByROIDsAndVersions";
|
||||
cm.Parameters.AddWithValue("@ROIDs", criteria.ROIDs);
|
||||
cm.Parameters.AddWithValue("@Versions", criteria.Versions);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read())
|
||||
this.Add(new DROUsageInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfoList.DataPortal_FetchByROIDsAndVersions", ex);
|
||||
throw new DbCslaException("DROUsageInfoList.DataPortal_FetchByROIDsAndVersions", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,12 +351,19 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst, string versionList)
|
||||
{
|
||||
//DateTime dtStart = DateTime.Now;
|
||||
//DateTime dtLast = DateTime.Now;
|
||||
ROFSTLookup origLU = new ROFSTLookup(origROFstInfo);
|
||||
//dtLast = ShowDuration(dtLast, "origLU");
|
||||
ROFSTLookup newLU = new ROFSTLookup(newROFst);
|
||||
//dtLast = ShowDuration(dtLast, "newLU");
|
||||
List<string> delList = new List<string>();
|
||||
List<string> chgList = newLU.GetValueDifferences(origLU, ref delList);
|
||||
//dtLast = ShowDuration(dtLast, "chgList");
|
||||
string RoidList = GetRoidList(newROFst.RODbID, chgList);
|
||||
List<string> activeRoids = BuildActiveROIDsForRoUsages(RoidList);
|
||||
//dtLast = ShowDuration(dtLast, "RoidList");
|
||||
List<string> activeRoids = BuildActiveROIDsForRoUsages(RoidList, versionList);
|
||||
//dtLast = ShowDuration(dtLast, "activeRoids");
|
||||
foreach (string chg in chgList)
|
||||
{
|
||||
if (activeRoids.Contains(chg))
|
||||
@ -389,7 +396,9 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
activeRoids = BuildActiveROIDsForDRoUsages(RoidList);
|
||||
//dtLast = ShowDuration(dtLast, "chg loop");
|
||||
activeRoids = BuildActiveROIDsForDRoUsages(RoidList, versionList);
|
||||
//dtLast = ShowDuration(dtLast, "activeRoids Doc");
|
||||
foreach (string chg in chgList)
|
||||
{
|
||||
if (activeRoids.Contains(chg))
|
||||
@ -408,6 +417,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
//dtLast = ShowDuration(dtLast, "chg loop Doc");
|
||||
foreach (string del in delList)
|
||||
{
|
||||
string desc = string.Format("Deleted RO: Value = {0}", origLU.GetRoValue(del));
|
||||
@ -437,6 +447,15 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
//dtLast = ShowDuration(dtLast, "delList");
|
||||
//dtStart = ShowDuration(dtStart, "Total");
|
||||
}
|
||||
|
||||
private static DateTime ShowDuration(DateTime dtLast, string message)
|
||||
{
|
||||
DateTime dtNext = DateTime.Now;
|
||||
Console.WriteLine("{0,10:#####0.00},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - dtLast.Ticks).TotalSeconds, message);
|
||||
return dtNext;
|
||||
}
|
||||
private static List<string> BuildActiveROIDsForRoUsages(string RoidList)
|
||||
{
|
||||
@ -453,6 +472,21 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
return activeRoids;
|
||||
}
|
||||
private static List<string> BuildActiveROIDsForRoUsages(string RoidList,string versions)
|
||||
{
|
||||
List<string> activeRoids = new List<string>();
|
||||
using (RoUsageInfoList activeList = RoUsageInfoList.GetROUSagesByROIDsAndVersions(RoidList,versions))
|
||||
{
|
||||
foreach (RoUsageInfo roui in activeList)
|
||||
{
|
||||
string roid = roui.ROID.ToUpper();
|
||||
if (roid.EndsWith("0000")) roid = roid.Substring(0, 12);
|
||||
if (!activeRoids.Contains(roid))
|
||||
activeRoids.Add(roid);
|
||||
}
|
||||
}
|
||||
return activeRoids;
|
||||
}
|
||||
private static List<string> BuildActiveROIDsForDRoUsages(string RoidList)
|
||||
{
|
||||
List<string> activeRoids = new List<string>();
|
||||
@ -468,6 +502,21 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
return activeRoids;
|
||||
}
|
||||
private static List<string> BuildActiveROIDsForDRoUsages(string RoidList,string versions)
|
||||
{
|
||||
List<string> activeRoids = new List<string>();
|
||||
using (DROUsageInfoList activeList = DROUsageInfoList.GetDROUsagesByROIDsAndVersions(RoidList,versions))
|
||||
{
|
||||
foreach (DROUsageInfo roui in activeList)
|
||||
{
|
||||
string roid = roui.ROID;
|
||||
if (roid.EndsWith("0000")) roid = roid.Substring(0, 12);
|
||||
if (!activeRoids.Contains(roid))
|
||||
activeRoids.Add(roid);
|
||||
}
|
||||
}
|
||||
return activeRoids;
|
||||
}
|
||||
private static string GetRoidList(int dbid, List<string> chgList)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(string.Format("{0}", dbid));
|
||||
|
@ -174,6 +174,73 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
[Serializable]
|
||||
private class GetROUsagesByROIDsAndVersionsCriteria
|
||||
{
|
||||
public GetROUsagesByROIDsAndVersionsCriteria(string roids, string versions)
|
||||
{
|
||||
_ROIDS = roids;
|
||||
_Versions = versions;
|
||||
}
|
||||
private string _ROIDS;
|
||||
public string ROIDS
|
||||
{
|
||||
get { return _ROIDS; }
|
||||
set { _ROIDS = value; }
|
||||
}
|
||||
private string _Versions;
|
||||
public string Versions
|
||||
{
|
||||
get { return _Versions; }
|
||||
set { _Versions = value; }
|
||||
}
|
||||
}
|
||||
public static RoUsageInfoList GetROUSagesByROIDsAndVersions(string roids,string versions)
|
||||
{
|
||||
try
|
||||
{
|
||||
RoUsageInfoList tmp = DataPortal.Fetch<RoUsageInfoList>(new GetROUsagesByROIDsAndVersionsCriteria(roids,versions));
|
||||
RoUsageInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ROUsageInfoList.FindROUSagesByROIDs", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetROUsagesByROIDsAndVersionsCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROUsageInfoList.DataPortal_FetchFindByRoids", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getRoUsagesByRoidsAndVersions";
|
||||
cm.Parameters.AddWithValue("@ROIDS", criteria.ROIDS);
|
||||
cm.Parameters.AddWithValue("@Versions", criteria.Versions);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read())
|
||||
this.Add(new RoUsageInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROUsageInfoList.DataPortal_FetchFindByRoidsAndVersions", ex);
|
||||
throw new DbCslaException("ROUsageInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
public partial class RoUsageInfo
|
||||
{
|
||||
|
@ -421,6 +421,7 @@ namespace Volian.Svg.Library
|
||||
}
|
||||
public partial class SvgImage : SvgPart
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
public override void Draw(PdfContentByte cb, SvgScale scale, Svg mySvg, SvgPartInheritance myParent)
|
||||
{
|
||||
SetupInheritance(myParent.MyInheritedSettings);
|
||||
@ -442,10 +443,20 @@ namespace Volian.Svg.Library
|
||||
{
|
||||
SetupInheritance(myParent.MyInheritedSettings);
|
||||
tmp.SaveState();
|
||||
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ImagePath);
|
||||
img.ScaleAbsolute(scale.M(Width), scale.M(Height));
|
||||
img.SetAbsolutePosition(scale.X(X), scale.Y(Y) - scale.M(img.ScaledHeight));
|
||||
tmp.AddImage(img);
|
||||
try
|
||||
{
|
||||
if (ImagePath != null)
|
||||
{
|
||||
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ImagePath);
|
||||
img.ScaleAbsolute(scale.M(Width), scale.M(Height));
|
||||
img.SetAbsolutePosition(scale.X(X), scale.Y(Y) - scale.M(img.ScaledHeight));
|
||||
tmp.AddImage(img);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//_MyLog.WarnFormat("SvgImage.Draw '{0}' {1} - {2}", ImagePath, ex.GetType().Name, ex.Message);
|
||||
}
|
||||
tmp.RestoreState();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user