public static Dictionary <string, List <TableStyleInfo> > GetTableStyleInfoWithItemsDictinary(string tableName, List <int> allRelatedIdentities) { var dict = new Dictionary <string, List <TableStyleInfo> >(); var entries = TableStyleManagerCache.GetAllTableStyles(); foreach (var pair in entries) { var arr = pair.Key.Split('$'); var identityFromKey = TranslateUtils.ToInt(arr[0]); var tableNameFromKey = arr[1]; if (!StringUtils.EqualsIgnoreCase(tableNameFromKey, tableName) || !allRelatedIdentities.Contains(identityFromKey)) { continue; } var styleInfo = pair.Value; var tableStyleInfoWithItemList = dict.ContainsKey(styleInfo.AttributeName) ? dict[styleInfo.AttributeName] : new List <TableStyleInfo>(); tableStyleInfoWithItemList.Add(styleInfo); dict[styleInfo.AttributeName] = tableStyleInfoWithItemList; } return(dict); }
public static bool IsExists(int relatedIdentity, string tableName, string attributeName) { var key = GetKey(relatedIdentity, tableName, attributeName); var entries = TableStyleManagerCache.GetAllTableStyles(); return(entries.Any(x => x.Key == key)); }
public static TableStyleInfo GetTableStyleInfo(int id) { var entries = TableStyleManagerCache.GetAllTableStyles(); var entry = entries.FirstOrDefault(x => x.Value != null && x.Value.Id == id); return(entry.IsDefault() ? null : entry.Value); }
public static List <TableStyleInfo> GetStyleInfoList(string tableName, List <int> relatedIdentities) { var allAttributeNames = new List <string>(); var styleInfoList = new List <TableStyleInfo>(); var entries = TableStyleManagerCache.GetAllTableStyles(); relatedIdentities = ParseRelatedIdentities(relatedIdentities); foreach (var relatedIdentity in relatedIdentities) { var startKey = GetKeyPrefix(relatedIdentity, tableName); var list = entries.Where(tuple => tuple.Key.StartsWith(startKey)).ToList(); foreach (var pair in list) { if (pair.IsDefault()) { continue; } if (!allAttributeNames.Contains(pair.Value.AttributeName)) { allAttributeNames.Add(pair.Value.AttributeName); styleInfoList.Add(pair.Value); } } } if (tableName == DataProvider.UserDao.TableName || tableName == DataProvider.ChannelDao.TableName || tableName == DataProvider.SiteDao.TableName) { if (tableName == DataProvider.UserDao.TableName) { foreach (var columnName in UserAttribute.TableStyleAttributes.Value) { if (!StringUtils.ContainsIgnoreCase(allAttributeNames, columnName)) { allAttributeNames.Add(columnName); styleInfoList.Add(GetDefaultUserTableStyleInfo(tableName, columnName)); } } } } else { var columnNames = TableColumnManager.GetTableColumnNameList(tableName, ContentAttribute.MetadataAttributes.Value); foreach (var columnName in columnNames) { if (!StringUtils.ContainsIgnoreCase(allAttributeNames, columnName)) { allAttributeNames.Add(columnName); styleInfoList.Add(GetDefaultContentTableStyleInfo(tableName, columnName)); } } } return(styleInfoList.OrderBy(styleInfo => styleInfo.Taxis == 0 ? int.MaxValue : styleInfo.Taxis).ToList()); }
//relatedIdentities从大到小,最后是0 public static TableStyleInfo GetTableStyleInfo(string tableName, string attributeName, List <int> relatedIdentities) { if (attributeName == null) { attributeName = string.Empty; } relatedIdentities = ParseRelatedIdentities(relatedIdentities); var entries = TableStyleManagerCache.GetAllTableStyles(); foreach (var relatedIdentity in relatedIdentities) { var key = GetKey(relatedIdentity, tableName, attributeName); var pair = entries.FirstOrDefault(x => x.Key == key && x.Value != null); if (pair.IsDefault()) { continue; } if (pair.Value != null) { return(pair.Value); } } if (tableName == DataProvider.UserDao.TableName || tableName == DataProvider.ChannelDao.TableName || tableName == DataProvider.SiteDao.TableName) { if (tableName == DataProvider.UserDao.TableName) { return(GetDefaultUserTableStyleInfo(tableName, attributeName)); } } else { return(GetDefaultContentTableStyleInfo(tableName, attributeName)); } return(new TableStyleInfo(0, 0, tableName, attributeName, 0, attributeName, string.Empty, false, InputType.Text, string.Empty, true, string.Empty)); }
public static void ClearCache() { TableStyleManagerCache.Clear(); }