Example #1
0
 public static string GetMcDataTypeName(McDataType mcDataType)
 {
     return GetMcDataTypeName(mcDataType.ToString());
 }
Example #2
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;
            }
        }
Example #3
0
 public static string GetMcDataTypeName(McDataType mcDataType)
 {
     return(GetMcDataTypeName(mcDataType.ToString()));
 }
Example #4
0
        /// <summary>
        /// Converts the type.
        /// </summary>
        /// <returns></returns>
        public static object ConvertType2McDataType(McDataType mcType, object obj)
        {
            Dictionary <McDataType, ConversionDelegate> mcDataTypeConv;

            if ((obj == null) || (obj == DBNull.Value))
            {
                return(null);
            }

            if (_conversionTable.TryGetValue(obj.GetType(), out mcDataTypeConv))
            {
                ConversionDelegate convDelegate;
                if (mcDataTypeConv.TryGetValue(mcType, out convDelegate))
                {
                    return(convDelegate(obj));
                }
            }

            String errMsg = String.Format("conversion from [{0}] to [{1}] not found", obj.GetType().ToString(), mcType.ToString());

            throw new ArgumentException(errMsg);
        }
Example #5
0
        /// <summary>
        /// Converts the type.
        /// </summary>
        /// <returns></returns>
        public static object ConvertType2McDataType(McDataType mcType, object obj)
        {
            Dictionary<McDataType, ConversionDelegate> mcDataTypeConv;

            if ((obj == null) || (obj == DBNull.Value))
                return null;

            if (_conversionTable.TryGetValue(obj.GetType(), out mcDataTypeConv))
            {
                ConversionDelegate convDelegate;
                if (mcDataTypeConv.TryGetValue(mcType, out convDelegate))
                    return convDelegate(obj);
            }

            String errMsg = String.Format("conversion from [{0}] to [{1}] not found", obj.GetType().ToString(), mcType.ToString());
            throw new ArgumentException(errMsg);
        }
Example #6
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;
            }
        }