本文整理汇总了C#中Kooboo.CMS.Content.Models.TextContent.GetSchema方法的典型用法代码示例。如果您正苦于以下问题:C# TextContent.GetSchema方法的具体用法?C# TextContent.GetSchema怎么用?C# TextContent.GetSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Content.Models.TextContent
的用法示例。
在下文中一共展示了TextContent.GetSchema方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public SqlCommand Add(TextContent textContent)
{
textContent = textContent.ConvertToUTCTime();
var schema = textContent.GetSchema().AsActual();
if (schema == null)
{
return null;
}
List<string> fields = new List<string>() {
"UUID", "Repository", "FolderName", "UserKey", "UtcCreationDate", "UtcLastModificationDate", "Published", "OriginalUUID",
"SchemaName","ParentFolder", "ParentUUID","UserId","OriginalRepository","OriginalFolder",
"IsLocalized","Sequence"
};
SqlCommand command = new SqlCommand();
command.Parameters.Add(new SqlParameter("@UUID", textContent.UUID));
command.Parameters.Add(new SqlParameter("@Repository", textContent.Repository));
command.Parameters.Add(new SqlParameter("@FolderName", textContent.FolderName));
command.Parameters.Add(new SqlParameter("@UserKey", textContent.UserKey));
command.Parameters.Add(new SqlParameter("@UtcCreationDate", textContent.UtcCreationDate));
command.Parameters.Add(new SqlParameter("@UtcLastModificationDate", textContent.UtcLastModificationDate));
command.Parameters.Add(new SqlParameter("@Published", textContent.Published));
command.Parameters.Add(new SqlParameter("@OriginalUUID", textContent.OriginalUUID));
command.Parameters.Add(new SqlParameter("@SchemaName", textContent.SchemaName));
command.Parameters.Add(new SqlParameter("@ParentFolder", textContent.ParentFolder));
command.Parameters.Add(new SqlParameter("@ParentUUID", textContent.ParentUUID));
command.Parameters.Add(new SqlParameter("@UserId", textContent.UserId));
command.Parameters.Add(new SqlParameter("@OriginalRepository", textContent.OriginalRepository));
command.Parameters.Add(new SqlParameter("@OriginalFolder", textContent.OriginalFolder));
command.Parameters.Add(new SqlParameter("@IsLocalized", textContent.IsLocalized));
command.Parameters.Add(new SqlParameter("@Sequence", textContent.Sequence));
foreach (var column in schema.Columns.Where(it => !it.IsSystemField))
{
fields.Add(string.Format("{0}", column.Name));
command.Parameters.Add(CreateParameter(column, textContent));
}
string sql = string.Format("INSERT INTO [{0}] ({1}) VALUES({2})", schema.GetTableName(),
string.Join(",", fields.Select(it => "[" + it + "]").ToArray()),
string.Join(",", fields.Select(it => "@" + it).ToArray()));
command.CommandText = sql;
return command;
}
示例2: ToXElement
private static XElement ToXElement(TextContent textContent)
{
var xelement = new XElement("file", new XAttribute("original", textContent.UUID), new XAttribute("source-language", textContent.Repository), new XAttribute("target-language", ""));
var bodyElement = new XElement("body");
xelement.Add(bodyElement);
var schema = textContent.GetSchema().AsActual();
if (schema != null)
{
foreach (var column in schema.Columns)
{
if (column.DataType == DataType.String)
{
var value = textContent[column.Name];
bodyElement.Add(new XElement("trans-unit", new XAttribute("id", column.Name), new XAttribute("datatype", value == null ? "null" : value.GetType().ToString()),
new XElement("source", value), new XElement("target", value)));
}
}
}
return xelement;
}
示例3: Delete
public SqlCommand Delete(TextContent textContext)
{
var schema = textContext.GetSchema();
SqlCommand command = new SqlCommand();
command.Parameters.Add(new SqlParameter("@UUID", textContext.UUID));
command.CommandText = string.Format("DELETE FROM [{0}] WHERE [email protected]", schema.GetTableName());
return command;
}
示例4: Update
public MySqlCommand Update(TextContent textContent)
{
textContent = textContent.ConvertToUTCTime();
var schema = textContent.GetSchema().AsActual();
List<string> fields = new List<string>() {
"Repository", "FolderName", "UserKey", "UtcCreationDate", "UtcLastModificationDate", "Published", "OriginalUUID",
"SchemaName","ParentFolder", "ParentUUID","UserId","OriginalRepository","OriginalFolder","IsLocalized","Sequence"
};
MySqlCommand command = new MySqlCommand();
command.Parameters.Add(new MySqlParameter("?UUID", textContent.UUID));
command.Parameters.Add(new MySqlParameter("?Repository", textContent.Repository));
command.Parameters.Add(new MySqlParameter("?FolderName", textContent.FolderName));
command.Parameters.Add(new MySqlParameter("?UserKey", textContent.UserKey));
command.Parameters.Add(new MySqlParameter("?UtcCreationDate", textContent.UtcCreationDate));
command.Parameters.Add(new MySqlParameter("?UtcLastModificationDate", textContent.UtcLastModificationDate));
command.Parameters.Add(new MySqlParameter("?Published", textContent.Published));
command.Parameters.Add(new MySqlParameter("?OriginalUUID", textContent.OriginalUUID));
command.Parameters.Add(new MySqlParameter("?SchemaName", textContent.SchemaName));
command.Parameters.Add(new MySqlParameter("?ParentFolder", textContent.ParentFolder));
command.Parameters.Add(new MySqlParameter("?ParentUUID", textContent.ParentUUID));
command.Parameters.Add(new MySqlParameter("?UserId", textContent.UserId));
command.Parameters.Add(new MySqlParameter("?OriginalRepository", textContent.OriginalRepository));
command.Parameters.Add(new MySqlParameter("?OriginalFolder", textContent.OriginalFolder));
command.Parameters.Add(new MySqlParameter("?IsLocalized", textContent.IsLocalized));
command.Parameters.Add(new MySqlParameter("?Sequence", textContent.Sequence));
foreach (var column in schema.Columns.Where(it => !it.IsSystemField))
{
fields.Add(string.Format("{0}", column.Name));
command.Parameters.Add(CreateParameter(column, textContent));
}
string sql = string.Format("UPDATE `{0}` SET {1} WHERE UUID=?UUID", schema.GetTableName()
, string.Join(",", fields.Select(it => "`" + it + "`" + "=?" + it)));
command.CommandText = sql;
return command;
}
示例5: QueryFieldDataType
private static FieldDataType QueryFieldDataType(TextContent data, string fieldName)
{
var dataType = FieldDataType.RichText;
fieldName = fieldName ?? string.Empty;
var column = data.GetSchema().AsActual().AllColumns
.Where(o => fieldName.Equals(o.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (column != null)
{
if ("TextBox".Equals(column.ControlType, StringComparison.OrdinalIgnoreCase) ||
"TextArea".Equals(column.ControlType, StringComparison.OrdinalIgnoreCase))
{
dataType = FieldDataType.Text;
}
else if ("Tinymce".Equals(column.ControlType, StringComparison.OrdinalIgnoreCase))
{
dataType = FieldDataType.RichText;
}
else if ("Date".Equals(column.ControlType, StringComparison.OrdinalIgnoreCase) ||
"DateTime".Equals(column.ControlType, StringComparison.OrdinalIgnoreCase))
{
dataType = FieldDataType.Date;
}
}
else
{
dataType = FieldDataType.RichText;
}
// ret
return dataType;
}
示例6: Update
public SqlCeCommand Update(TextContent textContent)
{
var schema = textContent.GetSchema().AsActual();
List<string> fields = new List<string>() {
"Repository", "FolderName", "UserKey", "UtcCreationDate", "UtcLastModificationDate", "Published",
"OriginalUUID", "SchemaName","ParentFolder", "ParentUUID","UserId","OriginalRepository","OriginalFolder",
"IsLocalized","Sequence"
};
SqlCeCommand command = new SqlCeCommand();
command.Parameters.Add(new SqlCeParameter("@UUID", textContent.UUID));
command.Parameters.Add(new SqlCeParameter("@Repository", textContent.Repository));
command.Parameters.Add(new SqlCeParameter("@FolderName", textContent.FolderName));
command.Parameters.Add(new SqlCeParameter("@UserKey", textContent.UserKey));
command.Parameters.Add(new SqlCeParameter("@UtcCreationDate", textContent.UtcCreationDate));
command.Parameters.Add(new SqlCeParameter("@UtcLastModificationDate", textContent.UtcLastModificationDate));
command.Parameters.Add(new SqlCeParameter("@Published", textContent.Published));
command.Parameters.Add(new SqlCeParameter("@OriginalUUID", textContent.OriginalUUID));
command.Parameters.Add(new SqlCeParameter("@SchemaName", textContent.SchemaName));
command.Parameters.Add(new SqlCeParameter("@ParentFolder", textContent.ParentFolder));
command.Parameters.Add(new SqlCeParameter("@ParentUUID", textContent.ParentUUID));
command.Parameters.Add(new SqlCeParameter("@UserId", textContent.UserId));
command.Parameters.Add(new SqlCeParameter("@OriginalRepository", textContent.OriginalRepository));
command.Parameters.Add(new SqlCeParameter("@OriginalFolder", textContent.OriginalFolder));
command.Parameters.Add(new SqlCeParameter("@IsLocalized", textContent.IsLocalized));
command.Parameters.Add(new SqlCeParameter("@Sequence", textContent.Sequence));
foreach (var column in schema.Columns.Where(it => !it.IsSystemField))
{
fields.Add(string.Format("{0}", column.Name));
command.Parameters.Add(CreateParameter(column, textContent));
}
string sql = string.Format("UPDATE [{0}] SET {1} WHERE [email protected]", schema.GetTableName()
, string.Join(",", fields.Select(it => "[" + it + "]" + "[email protected]" + it)));
command.CommandText = sql;
return command;
}