Example #1
0
        public void Load(mcweb_MetaViewPreferenceRow preferenceRow, List <string> availableFieldNames)
        {
            _columns.Clear();

            if (preferenceRow != null)
            {
                Dictionary <string, ColumnInfo> columnsByName = new Dictionary <string, ColumnInfo>();

                McMetaViewPreference preference = UserMetaViewPreference.GetPreferenceFromString(preferenceRow.XSMetaViewPreference);
                AttributeCollection  attributes = preference.Attributes;

                for (int i = 0; i < attributes.Count; i++)
                {
                    string key = attributes.Keys[i];

                    string[] parts = key.Split(':');
                    if (parts.Length == 2)
                    {
                        string fieldName = parts[0];
                        if (availableFieldNames.Contains(fieldName))
                        {
                            ColumnInfo column;
                            if (columnsByName.ContainsKey(fieldName))
                            {
                                column = columnsByName[fieldName];
                            }
                            else
                            {
                                column = new ColumnInfo(fieldName);
                                columnsByName.Add(fieldName, column);
                            }

                            string attributeName = parts[1];
                            object value         = attributes[key];

                            switch (attributeName)
                            {
                            case "Index":
                                column.Index = (int)value;
                                break;

                            case "Width":
                                column.Width = (int)value;
                                break;
                            }
                        }
                    }
                }
                _columns.AddRange(columnsByName.Values);
                // Sort columns by index.
                _columns.Sort();
            }
            else
            {
                foreach (string name in availableFieldNames)
                {
                    _columns.Add(new ColumnInfo(name));
                }
            }
        }
Example #2
0
        internal void Load(MetaView metaView)
        {
            _metaClassName       = metaView.MetaClassName;
            _availableFieldNames = metaView.AvailableFieldNames;

            List <string> fieldNames = new List <string>(_availableFieldNames);

            mcweb_MetaViewPreferenceRow[] preferenceRows = mcweb_MetaViewPreferenceRow.List(FilterElement.EqualElement("MetaViewName", metaView.Name), FilterElement.IsNullElement("PrincipalId"));
            if (preferenceRows.Length == 0)
            {
                preferenceRows = new mcweb_MetaViewPreferenceRow[] { null };
            }

            foreach (mcweb_MetaViewPreferenceRow preferenceRow in preferenceRows)
            {
                MetaViewPreferenceInfo preferenceInfo = new MetaViewPreferenceInfo();
                preferenceInfo.Load(preferenceRow, fieldNames);
                _preferences.Add(preferenceInfo);
            }
        }
Example #3
0
        internal void Load(MetaView metaView)
        {
            _metaClassName = metaView.MetaClassName;
            _availableFieldNames = metaView.AvailableFieldNames;

            List<string> fieldNames = new List<string>(_availableFieldNames);

            mcweb_MetaViewPreferenceRow[] preferenceRows = mcweb_MetaViewPreferenceRow.List(FilterElement.EqualElement("MetaViewName", metaView.Name), FilterElement.IsNullElement("PrincipalId"));
            if(preferenceRows.Length == 0)
            {
                preferenceRows = new mcweb_MetaViewPreferenceRow[] { null };
            }

            foreach (mcweb_MetaViewPreferenceRow preferenceRow in preferenceRows)
            {
                MetaViewPreferenceInfo preferenceInfo = new MetaViewPreferenceInfo();
                preferenceInfo.Load(preferenceRow, fieldNames);
                _preferences.Add(preferenceInfo);
            }
        }