More datalayer optimizations

[TFS Changeset #65677]
This commit is contained in:
Shandem
2010-04-21 16:22:13 +00:00
parent 0a5673beea
commit 7c2b936073
9 changed files with 668 additions and 518 deletions

View File

@@ -805,7 +805,6 @@ order by level,sortOrder";
HasChildren = hasChildren;
}
/// <summary>
/// Updates the temp path for the content tree.
/// </summary>

File diff suppressed because it is too large Load Diff

View File

@@ -85,11 +85,13 @@ namespace umbraco.cms.businesslogic
#endregion
#region Constants
private const string m_SQLOptimizedGetAll = @"
SELECT id, createDate, trashed, parentId, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text,
masterContentType,Alias,icon,thumbnail,description
FROM umbracoNode INNER JOIN cmsContentType ON umbracoNode.id = cmsContentType.nodeId
WHERE nodeObjectType = @nodeObjectType";
WHERE nodeObjectType = @nodeObjectType";
#endregion
#region Static Methods
@@ -181,7 +183,7 @@ namespace umbraco.cms.businesslogic
#region Private Members
private bool _optimizedMode = false;
//private bool _optimizedMode = false;
private string _alias;
private string _iconurl;
private string _description;
@@ -195,9 +197,6 @@ namespace umbraco.cms.businesslogic
#endregion
//private static Hashtable _analyzedContentTypes = new Hashtable();
//private static Hashtable _optimizedContentTypes = new Hashtable();
#region Public Properties
/// <summary>
@@ -238,15 +237,15 @@ namespace umbraco.cms.businesslogic
}
}
/// <summary>
/// Gets or sets a value indicating whether [optimized mode].
/// </summary>
/// <value><c>true</c> if [optimized mode]; otherwise, <c>false</c>.</value>
public bool OptimizedMode
{
get { return _optimizedMode; }
set { _optimizedMode = value; }
}
///// <summary>
///// Gets or sets a value indicating whether [optimized mode].
///// </summary>
///// <value><c>true</c> if [optimized mode]; otherwise, <c>false</c>.</value>
//public bool OptimizedMode
//{
// get { return _optimizedMode; }
// set { _optimizedMode = value; }
//}
/// <summary>
/// Human readable name/label
@@ -394,35 +393,7 @@ namespace umbraco.cms.businesslogic
{
get
{
//optimize, lazy load the data only one time
if (m_VirtualTabs == null)
{
m_VirtualTabs = new List<TabI>();
using (IRecordsReader dr = SqlHelper.ExecuteReader(
string.Format(
"Select Id,text,sortOrder from cmsTab where contenttypeNodeId = {0} order by sortOrder",
Id)))
{
while (dr.Read())
{
m_VirtualTabs.Add(new Tab(dr.GetInt("id"), dr.GetString("text"), dr.GetInt("sortOrder"), this));
}
}
// Master Content Type
if (MasterContentType != 0)
{
foreach (TabI t in ContentType.GetContentType(MasterContentType).getVirtualTabs.ToList())
{
m_VirtualTabs.Add(t);
}
}
// sort all tabs
m_VirtualTabs.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder));
}
EnsureVirtualTabs();
return m_VirtualTabs.ToArray();
}
}
@@ -750,17 +721,72 @@ namespace umbraco.cms.businesslogic
if (HttpRuntime.Cache[string.Format("ContentType_PropertyTypes_Content:{0}", Id.ToString())] != null)
HttpRuntime.Cache.Remove(string.Format("ContentType_PropertyTypes_Content:{0}", Id.ToString()));
ClearVirtualTabs();
}
protected void FlushAllFromCache()
{
cache.Cache.ClearCacheByKeySearch("UmbracoContentType");
cache.Cache.ClearCacheByKeySearch("ContentType_PropertyTypes_Content");
ClearVirtualTabs();
}
#endregion
#region Private Methods
/// <summary>
/// Clears the locally loaded tabs which forces them to be reloaded next time they requested
/// </summary>
private void ClearVirtualTabs()
{
m_VirtualTabs = null;
}
/// <summary>
/// Checks if we've loaded the virtual tabs into memory and if not gets them from the databse.
/// </summary>
private void EnsureVirtualTabs()
{
//optimize, lazy load the data only one time
if (m_VirtualTabs == null)
{
InitializeVirtualTabs();
}
}
/// <summary>
/// Loads the tabs into memory from the database and stores them in a local list for retreival
/// </summary>
private void InitializeVirtualTabs()
{
m_VirtualTabs = new List<TabI>();
using (IRecordsReader dr = SqlHelper.ExecuteReader(
string.Format(
"Select Id,text,sortOrder from cmsTab where contenttypeNodeId = {0} order by sortOrder",
Id)))
{
while (dr.Read())
{
m_VirtualTabs.Add(new Tab(dr.GetInt("id"), dr.GetString("text"), dr.GetInt("sortOrder"), this));
}
}
// Master Content Type
if (MasterContentType != 0)
{
foreach (TabI t in ContentType.GetContentType(MasterContentType).getVirtualTabs.ToList())
{
m_VirtualTabs.Add(t);
}
}
// sort all tabs
m_VirtualTabs.Sort((a, b) => a.SortOrder.CompareTo(b.SortOrder));
}
private void PopulateContentTypeNodeFromReader(IRecordsReader dr)
{
_alias = dr.GetString("Alias");

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Xml;
using umbraco.cms.businesslogic.property;
using umbraco.cms.businesslogic.propertytype;
using umbraco.DataLayer;
using System.Runtime.CompilerServices;
using umbraco.cms.helpers;
namespace umbraco.cms.businesslogic
{
/// <summary>
/// Not implemented
/// </summary>
public interface ISaveHandlerContents
{
/// <summary>
/// Not implemented
/// </summary>
bool Execute(cms.businesslogic.Content contentObject);
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Runtime.CompilerServices;
using System.Xml;
using umbraco.DataLayer;
using umbraco.BusinessLogic;
namespace umbraco.cms.businesslogic.property
{
public class Properties : List<Property> { }
}

View File

@@ -108,9 +108,4 @@ namespace umbraco.cms.businesslogic.property
}
}
public class Properties : List<property.Property>
{
}
}

View File

@@ -223,8 +223,8 @@ namespace umbraco.cms.businesslogic.web
// special for tree performance
private int _userId = -1;
private Dictionary<Property, object> _knownProperties = new Dictionary<Property, object>();
private Func<KeyValuePair<Property, object>, string, bool> propertyTypeByAlias = (pt, alias) => pt.Key.PropertyType.Alias == alias;
//private Dictionary<Property, object> _knownProperties = new Dictionary<Property, object>();
//private Func<KeyValuePair<Property, object>, string, bool> propertyTypeByAlias = (pt, alias) => pt.Key.PropertyType.Alias == alias;
#endregion
/// <summary>
@@ -232,41 +232,41 @@ namespace umbraco.cms.businesslogic.web
/// </summary>
/// <param name="alias"></param>
/// <returns></returns>
public object this[string alias]
{
get
{
if (this._optimizedMode)
{
return this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Value;
}
else
{
return this.getProperty(alias).Value;
}
}
set
{
if (this._optimizedMode)
{
if (this._knownProperties.SingleOrDefault(p => propertyTypeByAlias(p, alias)).Key == null)
{
var pt = this.getProperty(alias);
//public object this[string alias]
//{
// get
// {
// if (this._optimizedMode)
// {
// return this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Value;
// }
// else
// {
// return this.getProperty(alias).Value;
// }
// }
// set
// {
// if (this._optimizedMode)
// {
// if (this._knownProperties.SingleOrDefault(p => propertyTypeByAlias(p, alias)).Key == null)
// {
// var pt = this.getProperty(alias);
this._knownProperties.Add(pt, pt.Value);
}
else
{
var pt = this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Key;
this._knownProperties[pt] = value;
}
}
else
{
this.getProperty(alias).Value = value;
}
}
}
// this._knownProperties.Add(pt, pt.Value);
// }
// else
// {
// var pt = this._knownProperties.Single(p => propertyTypeByAlias(p, alias)).Key;
// this._knownProperties[pt] = value;
// }
// }
// else
// {
// this.getProperty(alias).Value = value;
// }
// }
//}
/// <summary>
/// Gets a value indicating whether the document was constructed for the optimized mode
@@ -570,14 +570,14 @@ namespace umbraco.cms.businesslogic.web
if (!e.Cancel)
{
if (this._optimizedMode)
{
foreach (var property in this._knownProperties)
{
var pt = property.Key;
pt.Value = property.Value;
}
}
//if (this._optimizedMode)
//{
// foreach (var property in this._knownProperties)
// {
// var pt = property.Key;
// pt.Value = property.Value;
// }
//}
base.Save();
// update preview xml

View File

@@ -172,11 +172,13 @@
<Compile Include="Actions\IActionHandler.cs" />
<Compile Include="businesslogic\CMSPreviewNode.cs" />
<Compile Include="businesslogic\datatype\ClientDependencyAttribute.cs" />
<Compile Include="businesslogic\ISaveHandlerContents.cs" />
<Compile Include="businesslogic\Packager\FileResources\PackageFiles.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>PackageFiles.resx</DependentUpon>
</Compile>
<Compile Include="businesslogic\Property\Properties.cs" />
<Compile Include="businesslogic\task\Tasks.cs" />
<Compile Include="helpers\Casing.cs" />
<Compile Include="Properties\AssemblyInfo.cs">

View File

@@ -4,7 +4,7 @@
<!-- Set up a local connection string -->
<xsl:template match="/configuration/appSettings/add[@key='umbracoDbDSN']/@value">
<xsl:attribute name="value">server=.\sqlexpress;database=UmbracoTest5;user id=sa;password=test;Application Name=Umbraco41</xsl:attribute>
<xsl:attribute name="value">server=.\sqlexpress;database=UmbracoTest4;user id=sa;password=test;Application Name=Umbraco41</xsl:attribute>
</xsl:template>
<xsl:template match="/configuration/appSettings/add[@key='umbracoConfigurationStatus']/@value">