When trying to query the umbracoApp table, check if it exists first

In the package installer, after creating a docType, also save it (now required)
In DocumentType, use the whole contentType to new-up a docType and check if the
allowedtemplate isn't null
Properties can have empty strings as values, can't convert those to int/datetime
Seperator character in ExpressionHelper was string.Empty, got malformed queries
This commit is contained in:
Sebastiaan Janssen
2012-12-20 16:20:56 -01:00
parent 9f2d41286c
commit 9334f55fa6
5 changed files with 28 additions and 20 deletions

View File

@@ -54,11 +54,11 @@ namespace Umbraco.Core.Persistence.Factories
if (property.HasIdentity)
dto.Id = property.Id;
if (property.DataTypeDatabaseType == DataTypeDatabaseType.Integer && property.Value != null)
if (property.DataTypeDatabaseType == DataTypeDatabaseType.Integer && property.Value != null && string.IsNullOrWhiteSpace(property.Value.ToString()) == false)
{
dto.Integer = int.Parse(property.Value.ToString());
}
else if (property.DataTypeDatabaseType == DataTypeDatabaseType.Date && property.Value != null)
else if (property.DataTypeDatabaseType == DataTypeDatabaseType.Date && property.Value != null && string.IsNullOrWhiteSpace(property.Value.ToString()) == false)
{
dto.Date = DateTime.Parse(property.Value.ToString());
}

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Core.Persistence.Querying
IList<string> updateFields = new List<string>();
IList<string> insertFields = new List<string>();
private string sep = string.Empty;
private string sep = " ";
private bool useFieldName = false;
private Database.PocoData pd;

View File

@@ -3,6 +3,7 @@ using System.Data.SqlClient;
using System.Linq;
using System.Xml.Linq;
using Umbraco.Core;
using Umbraco.Core.Persistence;
using umbraco.BusinessLogic.Utils;
using umbraco.DataLayer;
using umbraco.businesslogic;
@@ -58,20 +59,25 @@ namespace umbraco.BusinessLogic
new XAttribute("icon", attr.Icon),
new XAttribute("sortOrder", attr.SortOrder)));
}
var dbApps = SqlHelper.ExecuteReader("SELECT * FROM umbracoApp WHERE appAlias NOT IN (" + inString + ")");
while (dbApps.Read())
{
doc.Root.Add(new XElement("add",
new XAttribute("alias", dbApps.GetString("appAlias")),
new XAttribute("name", dbApps.GetString("appName")),
new XAttribute("icon", dbApps.GetString("appIcon")),
new XAttribute("sortOrder", dbApps.GetByte("sortOrder"))));
}
var db = ApplicationContext.Current.DatabaseContext.Database;
var exist = db.TableExist("umbracoApp");
if (exist)
{
var dbApps = SqlHelper.ExecuteReader("SELECT * FROM umbracoApp WHERE appAlias NOT IN (" + inString + ")");
while (dbApps.Read())
{
doc.Root.Add(new XElement("add",
new XAttribute("alias", dbApps.GetString("appAlias")),
new XAttribute("name", dbApps.GetString("appName")),
new XAttribute("icon", dbApps.GetString("appIcon")),
new XAttribute("sortOrder", dbApps.GetByte("sortOrder"))));
}
}
}, true);
//TODO Shouldn't this be enabled and then delete the whole table?
//SqlHelper.ExecuteNonQuery("DELETE FROM umbracoApp");
}
}

View File

@@ -856,6 +856,7 @@ namespace umbraco.cms.businesslogic.packager
foreach (DocumentType.TabI t in dt.getVirtualTabs.ToList())
DocumentType.FlushTabCache(t.Id, dt.Id);
dt.Save();
}
/// <summary>

View File

@@ -29,7 +29,8 @@ namespace umbraco.cms.businesslogic.web
public DocumentType(int id, bool noSetup) : base(id, noSetup) { }
internal DocumentType(IContentType contentType) : base(contentType)
internal DocumentType(IContentType contentType)
: base(contentType)
{
SetupNode(contentType);
}
@@ -123,7 +124,7 @@ namespace umbraco.cms.businesslogic.web
return dtd.ToString();
}
[Obsolete("Deprecated, Use Umbraco.Core.Services.ContentTypeService.GetContentType()", false)]
public new static DocumentType GetByAlias(string Alias)
{
@@ -143,7 +144,7 @@ namespace umbraco.cms.businesslogic.web
{
var contentType = new Umbraco.Core.Models.ContentType(-1) { Name = Text, Alias = Text, CreatorId = u.Id, Thumbnail = "folder.png", Icon = "folder.gif" };
ApplicationContext.Current.Services.ContentTypeService.Save(contentType, u.Id);
var newDt = new DocumentType(contentType.Id);
var newDt = new DocumentType(contentType);
//event
NewEventArgs e = new NewEventArgs();
@@ -459,7 +460,7 @@ namespace umbraco.cms.businesslogic.web
_defaultTemplate = 0;
var template = _contentType.DefaultTemplate;
if(template != null)
if (template != null)
_contentType.RemoveTemplate(template);
//SqlHelper.ExecuteNonQuery("update cmsDocumentType set IsDefault = 0 where contentTypeNodeId = " + Id.ToString());
@@ -531,7 +532,7 @@ namespace umbraco.cms.businesslogic.web
private void SetupNode(IContentType contentType)
{
_contentType = contentType;
foreach (var template in _contentType.AllowedTemplates)
foreach (var template in _contentType.AllowedTemplates.Where(t => t != null))
{
_templateIds.Add(template.Id);
}