Merge branch 'refs/heads/dev-v7.6' into temp-u4-9322
# Conflicts: # build/UmbracoVersion.txt # src/SolutionInfo.cs # src/Umbraco.Core/Configuration/UmbracoVersion.cs # src/Umbraco.Core/Services/ContentService.cs # src/Umbraco.Core/Services/ContentTypeService.cs # src/Umbraco.Core/Services/DataTypeService.cs # src/Umbraco.Core/Services/MacroService.cs # src/Umbraco.Core/Services/MediaService.cs # src/Umbraco.Core/Services/MemberService.cs # src/Umbraco.Core/Services/MemberTypeService.cs # src/Umbraco.Core/Services/UserService.cs # src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
@@ -351,7 +351,7 @@ namespace umbraco.cms.businesslogic.Tags
|
||||
{
|
||||
Document cnode = new Document(rr.GetInt("nodeid"));
|
||||
|
||||
if (cnode != null && cnode.Published)
|
||||
if (cnode.Published)
|
||||
docs.Add(cnode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,32 +54,31 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
public PropertyType(int id)
|
||||
{
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr = sqlHelper.ExecuteReader(
|
||||
"Select mandatory, DataTypeId, propertyTypeGroupId, ContentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id",
|
||||
sqlHelper.CreateParameter("@id", id)))
|
||||
var found = ApplicationContext.Current.DatabaseContext.Database
|
||||
.SingleOrDefault<dynamic>(
|
||||
"Select mandatory, DataTypeId, propertyTypeGroupId, contentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id",
|
||||
new {id = id});
|
||||
|
||||
if (found == null)
|
||||
throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!");
|
||||
|
||||
_mandatory = found.mandatory;
|
||||
_id = id;
|
||||
|
||||
if (found.propertyTypeGroupId != null)
|
||||
{
|
||||
if (!dr.Read())
|
||||
throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!");
|
||||
|
||||
_mandatory = dr.GetBoolean("mandatory");
|
||||
_id = id;
|
||||
|
||||
if (!dr.IsNull("propertyTypeGroupId"))
|
||||
{
|
||||
_propertyTypeGroup = dr.GetInt("propertyTypeGroupId");
|
||||
//TODO: Remove after refactoring!
|
||||
_tabId = _propertyTypeGroup;
|
||||
}
|
||||
|
||||
_sortOrder = dr.GetInt("sortOrder");
|
||||
_alias = dr.GetString("alias");
|
||||
_name = dr.GetString("Name");
|
||||
_validationRegExp = dr.GetString("validationRegExp");
|
||||
_DataTypeId = dr.GetInt("DataTypeId");
|
||||
_contenttypeid = dr.GetInt("contentTypeId");
|
||||
_description = dr.GetString("description");
|
||||
_propertyTypeGroup = found.propertyTypeGroupId;
|
||||
//TODO: Remove after refactoring!
|
||||
_tabId = _propertyTypeGroup;
|
||||
}
|
||||
|
||||
_sortOrder = found.sortOrder;
|
||||
_alias = found.alias;
|
||||
_name = found.name;
|
||||
_validationRegExp = found.validationRegExp;
|
||||
_DataTypeId = found.DataTypeId;
|
||||
_contenttypeid = found.contentTypeId;
|
||||
_description = found.description;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -92,7 +91,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_DataTypeId = value.Id;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery(
|
||||
"Update cmsPropertyType set DataTypeId = " + value.Id + " where id=" + Id);
|
||||
@@ -119,7 +117,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
{
|
||||
_tabId = value;
|
||||
PropertyTypeGroup = value;
|
||||
InvalidateCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +145,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_mandatory = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set mandatory = @mandatory where id = @id",
|
||||
sqlHelper.CreateParameter("@mandatory", value),
|
||||
@@ -162,7 +158,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_validationRegExp = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set validationRegExp = @validationRegExp where id = @id",
|
||||
sqlHelper.CreateParameter("@validationRegExp", value), sqlHelper.CreateParameter("@id", Id));
|
||||
@@ -199,7 +194,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_description = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set description = @description where id = @id",
|
||||
sqlHelper.CreateParameter("@description", value),
|
||||
@@ -213,7 +207,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_sortOrder = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set sortOrder = @sortOrder where id = @id",
|
||||
sqlHelper.CreateParameter("@sortOrder", value),
|
||||
@@ -227,7 +220,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_alias = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set alias = @alias where id= @id",
|
||||
sqlHelper.CreateParameter("@alias", Casing.SafeAliasWithForcingCheck(_alias)),
|
||||
@@ -264,7 +256,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery(
|
||||
"UPDATE cmsPropertyType SET name=@name WHERE id=@id",
|
||||
@@ -331,17 +322,17 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
public static IEnumerable<PropertyType> GetPropertyTypes()
|
||||
{
|
||||
var result = new List<PropertyType>();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr =
|
||||
sqlHelper.ExecuteReader("select id from cmsPropertyType order by Name"))
|
||||
|
||||
var propertyTypeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"select id from cmsPropertyType order by Name");
|
||||
|
||||
foreach (var propertyTypeId in propertyTypeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
PropertyType pt = GetPropertyType(dr.GetInt("id"));
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
PropertyType pt = GetPropertyType(propertyTypeId);
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -353,18 +344,17 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
public static IEnumerable<PropertyType> GetPropertyTypesByGroup(int groupId)
|
||||
{
|
||||
var result = new List<PropertyType>();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr =
|
||||
sqlHelper.ExecuteReader("SELECT id FROM cmsPropertyType WHERE propertyTypeGroupId = @groupId order by SortOrder",
|
||||
sqlHelper.CreateParameter("@groupId", groupId)))
|
||||
|
||||
var propertyTypeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"SELECT id FROM cmsPropertyType WHERE propertyTypeGroupId = @groupId order by SortOrder", new {groupId = groupId});
|
||||
|
||||
foreach (var propertyTypeId in propertyTypeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
PropertyType pt = GetPropertyType(dr.GetInt("id"));
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
PropertyType pt = GetPropertyType(propertyTypeId);
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -376,20 +366,18 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
public static IEnumerable<PropertyType> GetByDataTypeDefinition(int dataTypeDefId)
|
||||
{
|
||||
var result = new List<PropertyType>();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr =
|
||||
sqlHelper.ExecuteReader(
|
||||
"select id, Name from cmsPropertyType where dataTypeId=@dataTypeId order by Name",
|
||||
sqlHelper.CreateParameter("@dataTypeId", dataTypeDefId)))
|
||||
|
||||
var propertyTypeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"select id from cmsPropertyType where dataTypeId=@dataTypeId order by Name", new {dataTypeId = dataTypeDefId});
|
||||
|
||||
foreach (var propertyTypeId in propertyTypeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
PropertyType pt = GetPropertyType(dr.GetInt("id"));
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
PropertyType pt = GetPropertyType(propertyTypeId);
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
return result.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void delete()
|
||||
@@ -411,7 +399,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
// delete cache from either master (via tabid) or current contentype
|
||||
FlushCacheBasedOnTab();
|
||||
InvalidateCache();
|
||||
}
|
||||
|
||||
public void FlushCacheBasedOnTab()
|
||||
@@ -478,8 +465,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
protected virtual void FlushCache()
|
||||
{
|
||||
// clear local cache
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(GetCacheKey(Id));
|
||||
|
||||
// clear cache in contentype
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(CacheKeys.ContentTypePropertiesCacheKey + _contenttypeid);
|
||||
@@ -496,31 +481,9 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
public static PropertyType GetPropertyType(int id)
|
||||
{
|
||||
return ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem<PropertyType>(
|
||||
GetCacheKey(id),
|
||||
timeout: TimeSpan.FromMinutes(30),
|
||||
getCacheItem: () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PropertyType(id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InvalidateCache()
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(GetCacheKey(Id));
|
||||
}
|
||||
|
||||
private static string GetCacheKey(int id)
|
||||
{
|
||||
return CacheKeys.PropertyTypeCacheKey + id;
|
||||
return new PropertyType(id);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -433,21 +433,20 @@ namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
XmlDocument xd = new XmlDocument();
|
||||
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr = sqlHelper.ExecuteReader("select nodeId from cmsDocument"))
|
||||
var nodeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"select nodeId from cmsDocument");
|
||||
|
||||
foreach (var nodeId in nodeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
new Document(dr.GetInt("nodeId")).SaveXmlPreview(xd);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
LogHelper.Error<Document>("Error generating preview xml", ee);
|
||||
}
|
||||
new Document(nodeId).SaveXmlPreview(xd);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
LogHelper.Error<Document>("Error generating preview xml", ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user