public static bool EvaluateByRegex(this IEnumerable <FieldValue> filters, ContentBase content) { foreach (var field in filters) { if (content.ContainsKey(field.FieldName)) { var value = content[field.FieldName]; if (string.IsNullOrEmpty(field.Value)) { if (value == null || string.IsNullOrEmpty(value.ToString())) { continue; } else { return(false); } } if (Regex.IsMatch(value.ToString(), field.Value, RegexOptions.IgnoreCase)) { continue; } else { return(false); } } else { return(false); } } return(true); }
public virtual string Generate(ContentBase content) { string userKey = content.UserKey; if (string.IsNullOrEmpty(userKey)) { userKey = GetColumnValueForUserKey(content); } if (string.IsNullOrEmpty(userKey)) { userKey = content.UUID; } else { if (userKey.Length > 90) { userKey = userKey.Substring(0, 90); } var tmpUserKey = EscapeUserKey(content, userKey); int tries = 0; while (IfUserKeyExists(content, tmpUserKey)) { tries++; tmpUserKey = userKey + "-" + tries.ToString(); } userKey = tmpUserKey; } return(userKey); }
public virtual string Generate(ContentBase content) { string userKey = content.UserKey; if (string.IsNullOrEmpty(userKey)) { userKey = GetColumnValueForUserKey(content); } if (string.IsNullOrEmpty(userKey)) { userKey = content.UUID; } else { if (userKey.Length > 90) { userKey = userKey.Substring(0, 90); } var tmpUserKey = EscapeUserKey(content, userKey); int tries = 0; while (IfUserKeyExists(content, tmpUserKey)) { tries++; tmpUserKey = userKey + "-" + tries.ToString(); } userKey = tmpUserKey; } return userKey; }
public static bool EvaluateByRegex(this IEnumerable<FieldValue> filters, ContentBase content) { foreach (var field in filters) { if (content.ContainsKey(field.FieldName)) { var value = content[field.FieldName]; if (string.IsNullOrEmpty(field.Value)) { if (value == null || string.IsNullOrEmpty(value.ToString())) { continue; } else { return false; } } if (Regex.IsMatch(value.ToString(), field.Value, RegexOptions.IgnoreCase)) { continue; } else { return false; } } else { return false; } } return true; }
public virtual string Generate(ContentBase content) { string userKey = content.UserKey; if (string.IsNullOrEmpty(userKey)) { userKey = GetColumnValueForUserKey(content); } if (string.IsNullOrEmpty(userKey)) { userKey = content.UUID; } else { if (userKey.Length > 256) { userKey = userKey.Substring(0, 256); } var tmpUserKey = EscapeUserKey(content, userKey); int tries = 0; while (IfUserKeyExists(content, tmpUserKey)) { tries++; tmpUserKey = userKey + "-" + Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(tries); } userKey = tmpUserKey; } return userKey; }
public virtual string Generate(ContentBase content) { string userKey = content.UserKey; if (string.IsNullOrEmpty(userKey)) { userKey = GetColumnValueForUserKey(content); } if (string.IsNullOrEmpty(userKey)) { userKey = content.UUID; } else { if (userKey.Length > 256) { userKey = userKey.Substring(0, 256); } var escapedUserKey = EscapeUserKey(content, userKey); var tmpUserKey = escapedUserKey; int tries = 0; while (IfUserKeyExists(content, tmpUserKey)) { tries++; tmpUserKey = escapedUserKey + "-" + Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(tries); } userKey = tmpUserKey; } return(userKey); }
protected virtual bool IfUserKeyExists(ContentBase content, string userKey) { var repository = new Repository(content.Repository); if (content is TextContent) { var textContent = (TextContent)content; var schema = new Schema(repository, textContent.SchemaName); var contentExists = schema.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault(); if (contentExists != null) { return(contentExists.UUID != content.UUID); } return(false); } else if (content is MediaContent) { var mediaContent = (MediaContent)content; var folder = new MediaFolder(repository, mediaContent.FolderName); var contentExists = folder.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault(); if (contentExists != null) { return(contentExists.UUID != content.UUID); } return(false); } return(false); }
protected virtual string EscapeUserKey(ContentBase content, string userKey) { string tmpUserKey = userKey.StripAllTags(); //http://stackoverflow.com/questions/9565360/how-to-convert-utf-8-characters-to-ascii-for-use-in-a-url/9628594#9628594 tmpUserKey = RemoveDiacritics(tmpUserKey); Repository repository = content.GetRepository().AsActual(); tmpUserKey = Regex.Replace(tmpUserKey, repository.UserKeyReplacePattern, repository.UserKeyHyphens); return tmpUserKey; }
/// <summary> /// 排序系统字段的其它自定义字段值 /// </summary> /// <param name="content">The content.</param> /// <returns></returns> public static NameValueCollection ExcludeBasicFields(ContentBase content) { NameValueCollection values = new NameValueCollection(); foreach (var key in content.Keys.Where(key => !contentBasicFields.Contains(key, StringComparer.CurrentCultureIgnoreCase))) { if (content[key] != null) { values[key] = content[key].ToString(); } } return values; }
protected virtual string EscapeUserKey(ContentBase content, string userKey) { string tmpUserKey = userKey.StripAllTags(); //http://stackoverflow.com/questions/9565360/how-to-convert-utf-8-characters-to-ascii-for-use-in-a-url/9628594#9628594 tmpUserKey = RemoveDiacritics(tmpUserKey); Repository repository = content.GetRepository().AsActual(); tmpUserKey = Regex.Replace(tmpUserKey, repository.UserKeyReplacePattern, repository.UserKeyHyphens); return(tmpUserKey); }
/// <summary> /// Gets the summary. /// </summary> /// <param name="content">The content.</param> /// <returns></returns> public static string GetSummary(this ContentBase content) { if (content is TextContent) { var textContent = (TextContent)content; var schema = textContent.GetSchema().AsActual(); var summarizeField = schema.GetSummarizeColumn(); if (summarizeField != null && content.ContainsKey(summarizeField.Name)) { return(content[summarizeField.Name] == null ? "" : content[summarizeField.Name].ToString()); } return(""); } else { var mediaContent = (MediaContent)content; return(mediaContent.FileName); } }
protected virtual string GetColumnValueForUserKey(ContentBase content) { if (content is TextContent) { var textContent = (TextContent)content; var repository = new Repository(textContent.Repository); var schema = new Schema(repository, textContent.SchemaName).AsActual(); var summarizeField = schema.Columns.Where(it => it.Summarize == true).FirstOrDefault(); if (summarizeField == null || textContent[summarizeField.Name] == null) { return(textContent.UUID); } else { return(textContent[summarizeField.Name].ToString()); } } else if (content is MediaContent) { return(((MediaContent)content).FileName); } return(null); }
protected virtual string GetColumnValueForUserKey(ContentBase content) { if (content is TextContent) { var textContent = (TextContent)content; var repository = new Repository(textContent.Repository); var schema = new Schema(repository, textContent.SchemaName).AsActual(); var summarizeField = schema.Columns.Where(it => it.Summarize == true).FirstOrDefault(); if (summarizeField == null || textContent[summarizeField.Name] == null) { return textContent.UUID; } else { return textContent[summarizeField.Name].ToString(); } } else if (content is MediaContent) { return ((MediaContent)content).FileName; } return null; }
public virtual string Generate(ContentBase content) { string userKey = content.UserKey; //#warning sqlce test... // return userKey; if (string.IsNullOrEmpty(userKey)) { userKey = GetColumnValueForUserKey(content); if (!string.IsNullOrEmpty(userKey)) { Repository repository = content.GetRepository().AsActual(); userKey = TrimUserKey(userKey, repository.UserKeyReplacePattern, repository.UserKeyHyphens); } } if (string.IsNullOrEmpty(userKey)) { userKey = content.UUID; } else { if (userKey.Length > 90) { userKey = userKey.Substring(0, 90); } int tries = 0; string tmpUserKey = userKey.StripAllTags(); while (IfUserKeyExists(content, tmpUserKey)) { tries++; tmpUserKey = userKey + "-" + tries.ToString(); } userKey = tmpUserKey; } return(userKey); }
public virtual string Generate(ContentBase content) { string userKey = content.UserKey; //#warning sqlce test... // return userKey; if (string.IsNullOrEmpty(userKey)) { userKey = GetColumnValueForUserKey(content); if (!string.IsNullOrEmpty(userKey)) { Repository repository = content.GetRepository().AsActual(); userKey = TrimUserKey(userKey, repository.UserKeyReplacePattern, repository.UserKeyHyphens); } } if (string.IsNullOrEmpty(userKey)) { userKey = content.UUID; } else { if (userKey.Length > 90) { userKey = userKey.Substring(0, 90); } int tries = 0; string tmpUserKey = userKey.StripAllTags(); while (IfUserKeyExists(content, tmpUserKey)) { tries++; tmpUserKey = userKey + "-" + tries.ToString(); } userKey = tmpUserKey; } return userKey; }
public virtual string Generate(ContentBase content) { return UniqueIdGenerator.GetInstance().GetBase32UniqueId(16); }
protected virtual bool IfUserKeyExists(ContentBase content, string userKey) { var repository = new Repository(content.Repository); if (content is TextContent) { var textContent = (TextContent)content; var schema = new Schema(repository, textContent.SchemaName); var contentExists = schema.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault(); if (contentExists != null) { return contentExists.UUID != content.UUID; } return false; } else if (content is MediaContent) { var mediaContent = (MediaContent)content; var folder = new MediaFolder(repository, mediaContent.FolderName); var contentExists = folder.CreateQuery().WhereEquals("UserKey", userKey).FirstOrDefault(); if (contentExists != null) { return contentExists.UUID != content.UUID; } return false; } return false; }
public virtual string Generate(ContentBase content) { return(UniqueIdGenerator.GetInstance().GetBase32UniqueId(16)); }
public ContentIntegrateId(ContentBase content) : this(content.Repository, content.FolderName, content.UUID) { }
public override string Generate(ContentBase content) { return content.UserKey; }
/// <summary> /// Gets the repository. /// </summary> /// <param name="content">The content.</param> /// <returns></returns> public static Repository GetRepository(this ContentBase content) { return(new Repository(content.Repository)); }