protected void ReloadData() { // Hashtables DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("TableName", typeof(string))); dt.Columns.Add(new DataColumn("ObjectCount", typeof(int))); lock (ProviderStringDictionary.Dictionaries) { // Hashtables foreach (DictionaryEntry item in ProviderStringDictionary.Dictionaries) { if (item.Value is IProviderDictionary) { IProviderDictionary dict = (IProviderDictionary)item.Value; DataRow dr = dt.NewRow(); string resStringKey = "HashTableName." + ValidationHelper.GetIdentifier(item.Key); if (resStringKey.Length > 100) { resStringKey = resStringKey.Substring(0, 100); } dr["TableName"] = GetString(resStringKey); dr["ObjectCount"] = dict.Count; dt.Rows.Add(dr); } } } dt.DefaultView.Sort = "TableName ASC"; this.gridHashtables.DataSource = dt.DefaultView; this.gridHashtables.DataBind(); // Objects if (TypeInfo.TrackObjectInstances) { dt = new DataTable(); dt.Columns.Add(new DataColumn("ObjectType", typeof(string))); dt.Columns.Add(new DataColumn("ObjectCount", typeof(int))); foreach (TypeInfo info in TypeInfo.TypeInfos.Values) { DataRow dr = dt.NewRow(); dr["ObjectType"] = info.ObjectType; // Get the instances IList <BaseInfo> instances = info.GetInstances(); dr["ObjectCount"] = instances.Count; dt.Rows.Add(dr); } dt.DefaultView.Sort = "ObjectType ASC"; this.gridObjects.DataSource = dt.DefaultView; this.gridObjects.DataBind(); } }
/// <summary> /// Loads the dictionaries to the data table /// </summary> private DataTable LoadDictionaries() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("TableName", typeof(string))); dt.Columns.Add(new DataColumn("ObjectCount", typeof(int))); lock (ProviderStringDictionary.Dictionaries) { // Hashtables foreach (DictionaryEntry item in ProviderStringDictionary.Dictionaries) { if (item.Value is IProviderDictionary) { IProviderDictionary dict = (IProviderDictionary)item.Value; DataRow dr = dt.NewRow(); string resStringKey = "HashTableName." + ValidationHelper.GetIdentifier(item.Key); if (resStringKey.Length > 100) { resStringKey = resStringKey.Substring(0, 100); } // Try to get the resource string name string name = ResHelper.GetString(resStringKey, null, String.Empty); if (String.IsNullOrEmpty(name)) { BaseInfo obj = CMSObjectHelper.GetReadOnlyObject(dict.ObjectType); if (obj != null) { string res = null; // Known hashtable columns (ID, GUID, Name) if (dict.ColumnNames.EqualsCSafe(obj.TypeInfo.IDColumn, true)) { res = "hashtable.byid"; } else if (dict.ColumnNames.StartsWithCSafe(obj.TypeInfo.CodeNameColumn, true)) { res = "hashtable.byname"; } else if (dict.ColumnNames.StartsWithCSafe(obj.TypeInfo.GUIDColumn, true)) { res = "hashtable.byguid"; } // Generate the name automatically if (!String.IsNullOrEmpty(res)) { name = ResHelper.GetStringFormat(res, GetString("ObjectTasks." + dict.ObjectType.Replace(".", "_"))); } } } if (String.IsNullOrEmpty(name)) { name = resStringKey; } dr["TableName"] = name; dr["ObjectCount"] = dict.GetRealCount(); dt.Rows.Add(dr); } } } return(dt); }