예제 #1
0
        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() + "?')");
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            tblName.Text = lip.ListName;
            MetaField mf = null;

            if (ViewState["_field"] != null)
            {
                mf = lip.GetDestinationMetaField(ViewState["_field"].ToString());
            }

            if (mf != null)
            {
                NameTextBox.Text           = mf.Name;
                FriendlyNameTextBox.Text   = mf.FriendlyName;
                AllowNullsCheckBox.Checked = mf.IsNullable;
            }
            else
            {
                NameTextBox.Text           = "";
                FriendlyNameTextBox.Text   = "";
                AllowNullsCheckBox.Checked = true;
            }

            FieldTypeList.Items.Clear();
            // Building the FieldType list
            foreach (string mcDataType in Enum.GetNames(typeof(McDataType)))
            {
                if (!MetaDataBaseSection.CheckMetaFieldTypeVisibility("List_XXX", (McDataType)Enum.Parse(typeof(McDataType), mcDataType)))
                {
                    continue;
                }

                if ((mcDataType == McDataType.ReferencedField.ToString()) ||
                    (mcDataType == McDataType.Reference.ToString()) ||
                    (mcDataType == McDataType.BackReference.ToString()) ||
                    (mcDataType == McDataType.Card.ToString()) ||
                    (mcDataType == McDataType.Link.ToString()) ||
                    (mcDataType == McDataType.Complex.ToString()) ||
                    (mcDataType == McDataType.MultiReference.ToString()))
                {
                    continue;
                }
                else if (mcDataType == McDataType.Identifier.ToString())
                {
                    if (DataContext.Current.MetaModel.GetRegisteredTypes(McDataType.Identifier).Length <= 0)
                    {
                        continue;
                    }
                }

                FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
            }
            if (mf != null)
            {
                CHelper.SafeSelect(FieldTypeList, mf.GetOriginalMetaType().McDataType.ToString());
            }
            else
            {
                CHelper.SafeSelect(FieldTypeList, "String");
            }

            if (FieldTypeList.Items.Count > 0)
            {
                string typeName = String.Empty;
                if (mf != null)
                {
                    typeName = mf.TypeName;
                }
                BindFormats(typeName);
            }

            if (AutogenerateSystemNames)
            {
                NameRow.Visible = false;
            }
        }
예제 #3
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            TableLink.Text        = CHelper.GetResFileString(mc.FriendlyName);
            TableLink.NavigateUrl = String.Format("{0}?class={1}", ReturnUrl, mc.Name);

            if (mf == null)
            {
                List <ListItem> listItems = new List <ListItem>();

                // Building the FieldType list
                foreach (string mcDataType in Enum.GetNames(typeof(McDataType)))
                {
                    if (!MetaDataBaseSection.CheckMetaFieldTypeVisibility(mc, (McDataType)Enum.Parse(typeof(McDataType), mcDataType)))
                    {
                        continue;
                    }

                    if (mcDataType == McDataType.ReferencedField.ToString())
                    {
                        if (mc.GetReferences().Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.BackReference.ToString())
                    {
                        MetaField[] mfList = mc.FindReferencesWithoutBack();
                        if (mfList.Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Card.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Identifier.ToString())
                    {
                        if (DataContext.Current.MetaModel.GetRegisteredTypes(McDataType.Identifier).Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Link.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Complex.ToString())
                    {
                        if (MetaDataWrapper.GetFieldFormatsByType(mcDataType).Length <= 0)
                        {
                            continue;
                        }

                        // IBN 4.7 fix: check that the list has the TitleField
                        if (ListManager.MetaClassIsList(mc))
                        {
                            if (String.IsNullOrEmpty(mc.TitleFieldName))
                            {
                                continue;
                            }
                        }
                    }
                    else if (mcDataType == McDataType.Reference.ToString())
                    {
                        if (String.IsNullOrEmpty(mc.TitleFieldName))
                        {
                            continue;
                        }
                        // IBN 4.7 fix: check that exists at least one list to which we can make a reference
                        //if (ListManager.MetaClassIsList(mc))
                        //{
                        //    bool exists = false;
                        //    foreach (MetaClass metaClass in DataContext.Current.MetaModel.MetaClasses)
                        //    {
                        //        string name = metaClass.Name;
                        //        if (!metaClass.IsBridge && !metaClass.IsCard && !String.IsNullOrEmpty(metaClass.TitleFieldName) && ListManager.MetaClassIsList(name) && name != mc.Name)
                        //        {
                        //            // Check Security
                        //            int listId = ListManager.GetListIdByClassName(name);
                        //            if (Mediachase.IBN.Business.ListInfoBus.CanRead(listId))
                        //            {
                        //                exists = true;
                        //                break;
                        //            }
                        //        }
                        //    }

                        //    if (!exists)
                        //        continue;
                        //}
                    }

                    listItems.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
                    //FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
                }

                listItems.Sort(delegate(ListItem x, ListItem y) { return(x.Text.CompareTo(y.Text)); });

                FieldTypeList.Items.AddRange(listItems.ToArray());

                CHelper.SafeSelect(FieldTypeList, "String");

                if (ListManager.MetaClassIsList(mc))
                {
                    ListInfo li = ListManager.GetListInfoByMetaClassName(mc.Name);
                    if (li.IsTemplate)
                    {
                        trSelector.Visible = false;
                    }
                    else
                    {
                        mfs.BindData(mc.Name);
                    }
                }
                else
                {
                    mfs.BindData(mc.Name);
                }

                if (mfs.Count == 0)
                {
                    trSelector.Visible = false;
                }

                if (FieldTypeList.Items.Count > 0)
                {
                    BindFormats();
                }
            }
            else              // Edit
            {
                NameTextBox.Text    = mf.Name;
                NameTextBox.Enabled = false;

                FriendlyNameTextBox.Text = mf.FriendlyName;

                AllowNullsCheckBox.Checked = mf.IsNullable;
                AllowNullsCheckBox.Enabled = false;

                McDataType mcDataType = mf.GetOriginalMetaType().McDataType;
                FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType.ToString()));
                FieldTypeList.Enabled = false;

                FormatList.Items.Add(new ListItem(CHelper.GetResFileString(mf.GetOriginalMetaType().FriendlyName), mf.TypeName));
                FormatList.Enabled = false;

                if (FieldTypeList.SelectedValue != McDataType.Identifier.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.Enum.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.MultiReference.ToString() &&
                    MetaDataWrapper.GetFieldFormatsByType(FieldTypeList.SelectedValue).Length <= 1)
                {
                    FormatRow.Visible = false;
                }

                trSelector.Visible = false;

                ShowControl();
            }

            if (AutogenerateSystemNames)
            {
                NameRow.Visible = false;
            }
        }
예제 #4
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            TableLink.Text        = CHelper.GetResFileString(mc.FriendlyName);
            TableLink.NavigateUrl = String.Format("{0}?class={1}", ReturnUrl, mc.Name);

            if (mf == null)
            {
                // Building the FieldType list
                foreach (string mcDataType in Enum.GetNames(typeof(McDataType)))
                {
                    if (!MetaDataBaseSection.CheckMetaFieldTypeVisibility(mc, (McDataType)Enum.Parse(typeof(McDataType), mcDataType)))
                    {
                        continue;
                    }

                    if (mcDataType == McDataType.ReferencedField.ToString())
                    {
                        if (mc.GetReferences().Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.BackReference.ToString())
                    {
                        MetaField[] mfList = mc.FindReferencesWithoutBack();
                        if (mfList.Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Card.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Identifier.ToString())
                    {
                        if (DataContext.Current.MetaModel.GetRegisteredTypes(McDataType.Identifier).Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Link.ToString())
                    {
                        continue;
                    }
                    else if (mcDataType == McDataType.Complex.ToString())
                    {
                        if (MetaDataWrapper.GetFieldFormatsByType(mcDataType).Length <= 0)
                        {
                            continue;
                        }
                    }
                    else if (mcDataType == McDataType.Reference.ToString())
                    {
                    }

                    FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType));
                }

                CHelper.SafeSelect(FieldTypeList, "String");

                mfs.BindData(mc.Name);

                if (FieldTypeList.Items.Count > 0)
                {
                    BindFormats();
                }
            }
            else              // Edit
            {
                NameTextBox.Text    = mf.Name;
                NameTextBox.Enabled = false;

                FriendlyNameTextBox.Text = mf.FriendlyName;

                AllowNullsCheckBox.Checked = mf.IsNullable;
                AllowNullsCheckBox.Enabled = false;

                McDataType mcDataType = mf.GetOriginalMetaType().McDataType;
                FieldTypeList.Items.Add(new ListItem(CHelper.GetMcDataTypeName(mcDataType), mcDataType.ToString()));
                FieldTypeList.Enabled = false;

                FormatList.Items.Add(new ListItem(CHelper.GetResFileString(mf.GetOriginalMetaType().FriendlyName), mf.TypeName));
                FormatList.Enabled = false;

                if (FieldTypeList.SelectedValue != McDataType.Identifier.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.Enum.ToString() &&
                    FieldTypeList.SelectedValue != McDataType.MultiReference.ToString() &&
                    MetaDataWrapper.GetFieldFormatsByType(FieldTypeList.SelectedValue).Length <= 1)
                {
                    FormatRow.Visible = false;
                }

                trSelector.Visible = false;

                ShowControl();
            }

            if (AutogenerateSystemNames)
            {
                NameRow.Visible = false;
            }
        }