/// <summary> /// Default data bind. /// </summary> private void DefaultDataBind() { cbIsPublic.Visible = Mediachase.IBN.Business.Security.IsUserInGroup(Mediachase.IBN.Business.InternalSecureGroups.Administrator); List <ListItem> listItems = new List <ListItem>(); MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(_className); foreach (MetaField field in mc.Fields) { if (field.Attributes.ContainsKey(McDataTypeAttribute.AggregationMark)) { continue; } if (field.IsBackReference) { continue; } if (field.IsAggregation) { string aggrClassName = field.Attributes.GetValue <string>(McDataTypeAttribute.AggregationMetaClassName); MetaClass aggrClass = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(aggrClassName); foreach (MetaField aggrField in aggrClass.Fields) { ListItem li = new ListItem(CHelper.GetMetaFieldName(field) + "." + CHelper.GetMetaFieldName(aggrField), field.Name + "." + aggrField.Name); listItems.Add(li); } } else { ListItem li = new ListItem(CHelper.GetMetaFieldName(field), field.Name); listItems.Add(li); } } listItems.Sort(delegate(ListItem x, ListItem y) { return(x.Text.CompareTo(y.Text)); }); ListSelector.Items.AddRange(listItems.ToArray()); //ctrlFilter.Provider = new ListViewProfileExpressionProvider(); ctrlFilter.ProviderName = "MetaDataProvider"; ctrlFilter.DataSource = string.Format("{0}::{1}", _className, _placeName) + ";" + _uid; // "Contact::EntitySelect;EntitySelect"; ctrlFilter.DataBind(); }
private void BindList() { FieldList.Items.Clear(); if (!String.IsNullOrEmpty(ClassName)) { MetaClass mc = MetaDataWrapper.GetMetaClassByName(ClassName); HistoryMetaClassInfo historyInfo = HistoryManager.GetInfo(mc); Collection <string> selectedFields = historyInfo.SelectedFields; foreach (MetaField mf in mc.Fields) { if (HistoryManager.IsSupportedField(mf) && !selectedFields.Contains(mf.Name)) { FieldList.Items.Add(new ListItem(CHelper.GetMetaFieldName(mf), mf.Name)); } } } }
private void BindGrid() { MetaClass mc = MetaDataWrapper.GetMetaClassByName(ClassName); DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Type", typeof(string)); HistoryMetaClassInfo historyInfo = HistoryManager.GetInfo(mc); Collection <string> selectedFields = historyInfo.SelectedFields; foreach (string fieldName in selectedFields) { MetaField mf = mc.Fields[fieldName]; if (mf == null) { continue; } DataRow row = dt.NewRow(); row["Id"] = fieldName; row["Name"] = CHelper.GetMetaFieldName(mf); row["Type"] = CHelper.GetMcDataTypeName(mf.GetOriginalMetaType().McDataType); dt.Rows.Add(row); } MainGrid.DataSource = dt; MainGrid.DataBind(); foreach (GridViewRow row in MainGrid.Rows) { ImageButton ib = (ImageButton)row.FindControl("DeleteButton"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')"); } } }
private void AddItem(MetaField mf) { if (mf.IsAggregation) { string aggrClassName = mf.Attributes[McDataTypeAttribute.AggregationMetaClassName].ToString(); MetaClass mc = MetaDataWrapper.GetMetaClassByName(aggrClassName); foreach (MetaField mfa in mc.Fields) { ddField.Items.Add( new ListItem( String.Format("{0} - {1}", CHelper.GetMetaFieldName(mf), CHelper.GetMetaFieldName(mfa)), String.Format("{0}.{1}", mf.Name, mfa.Name) ) ); } } else { ddField.Items.Add(new ListItem(CHelper.GetMetaFieldName(mf), mf.Name)); } }
private void BindData() { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("FriendlyName", typeof(string)); dt.Columns.Add("TypeName", typeof(string)); dt.Columns.Add("IsSystem", typeof(bool)); dt.Columns.Add("FieldTypeImageUrl", typeof(string)); dt.Columns.Add("EditLink", typeof(string)); dt.Columns.Add("IsTitle", typeof(bool)); string titleField = mc.TitleFieldName; foreach (MetaField field in mc.Fields) { if (field.TypeName == "Reference") { // Ibn 4.7 Lists fix. if (!Mediachase.Ibn.Lists.ListManager.MetaClassIsList(mc)) { continue; } } DataRow row = dt.NewRow(); row["Name"] = field.Name; row["IsTitle"] = (field.Name == titleField); row["FriendlyName"] = CHelper.GetMetaFieldName(field); row["TypeName"] = CHelper.GetResFileString(field.GetOriginalMetaType().FriendlyName); row["IsSystem"] = field.Attributes.ContainsKey(MetaClassAttribute.IsSystem) || mc.TitleFieldName == field.Name; if (field.IsLink) { row["EditLink"] = String.Format("~/Apps/MetaDataBase/Pages/Admin/MetaLinkEdit.aspx?class={0}&field={1}", mc.Name, field.Name); } else { row["EditLink"] = String.Format("{0}?class={1}&field={2}", EditFieldLink, mc.Name, field.Name); } string postfix = string.Empty; if ((bool)row["IsSystem"]) { postfix = "_sys"; } if (field.TypeName == "ReferencedField") { row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture, "~/images/IbnFramework/metainfo/referencedfield{0}.gif", postfix); string refClassName = field.Attributes[McDataTypeAttribute.ReferenceMetaClassName].ToString(); row["TypeName"] = String.Format(CultureInfo.InvariantCulture, "{0} ({1})", CHelper.GetResFileString(field.GetMetaType().FriendlyName), CHelper.GetResFileString(MetaDataWrapper.GetMetaClassByName(refClassName).FriendlyName)); } else if (field.TypeName == "Reference") // Ibn 4.7 Lists { row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture, "~/images/IbnFramework/metainfo/reference{0}.gif", postfix); } /* else if (field.TypeName == "BackReference") * { * row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture, * "~/images/IbnFramework/metainfo/backreference{0}.gif", * postfix); * } */ else { row["FieldTypeImageUrl"] = String.Format(CultureInfo.InvariantCulture, "~/images/IbnFramework/metainfo/metafield{0}.gif", postfix); } dt.Rows.Add(row); } DataView dv = dt.DefaultView; if (_pc[sortKey] == null) { _pc[sortKey] = "FriendlyName"; } dv.Sort = _pc[sortKey]; grdMain.DataSource = dv; grdMain.DataBind(); foreach (GridViewRow row in grdMain.Rows) { ImageButton ib = (ImageButton)row.FindControl("ibDelete"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Delete").ToString() + "?')"); } } if (!ShowSystemInfo) { // grdMain.Columns[0].Visible = false; grdMain.Columns[1].Visible = false; } }