コード例 #1
1
		private ColumnCollection CollectionWith2Columns()
		{
			ColumnCollection cc = new ColumnCollection();
			cc.Add (new SortColumn("Column1",typeof(System.String)));
			cc.Add(new SortColumn("Column2",System.ComponentModel.ListSortDirection.Ascending,typeof(System.String),true));
			return cc;
			        
		}
コード例 #2
0
        public void CanWriteAndReadXmlOfCollectionWith2Columns()
        {
            var cc = new ColumnCollection();

            cc.Add(new Column {
                ClrType = typeof(string), DbType = "varchar", Name = "abc"
            });
            cc.Add(new Column {
                ClrType = typeof(int), DbType = "int", Name = "def"
            });

            using (var w = new TestXmlWriter())
            {
                new ColumnCollectionSerializer().Serialize(w.Writer, cc);

                using (var r = new TestXmlReader(w.Xml))
                {
                    var cc2 = new ColumnCollectionSerializer().Deserialize(r.Reader);

                    Assert.IsNotNull(cc2);
                    Assert.AreEqual(2, cc2.Count);
                    Assert.AreEqual("abc", cc2[0].Name, "abc");
                    Assert.AreEqual("varchar", cc2[0].DbType, "varchar");
                    Assert.AreSame(typeof(string), cc2[0].ClrType);
                    Assert.AreEqual("def", cc2[1].Name, "def");
                    Assert.AreEqual("int", cc2[1].DbType, "int");
                    Assert.AreEqual(typeof(int), cc2[1].ClrType);
                }
            }
        }
コード例 #3
0
        public void CanWriteXmlForColimnsWith2Columns()
        {
            var xml = new StringBuilder();

            xml.Append("<Columns>");
            xml.Append("<Column name=\"cola\" dbType=\"varchar\" clrType=\"System.String\" />");
            xml.Append("<Column name=\"colb\" dbType=\"int\" clrType=\"System.Int32\" />");
            xml.Append("</Columns>");

            var cc = new ColumnCollection();

            cc.Add(new Column {
                ClrType = typeof(string), DbType = "varchar", Name = "cola"
            });
            cc.Add(new Column {
                ClrType = typeof(int), DbType = "int", Name = "colb"
            });

            using (var w = new TestXmlWriter())
            {
                new ColumnCollectionSerializer().Serialize(w.Writer, cc);

                Assert.AreEqual(xml.ToString(), w.Xml);
            }
        }
コード例 #4
0
ファイル: Associational.cs プロジェクト: mjr129/metaboclust
            public void GetXColumns(CustomColumnRequest request)
            {
                ColumnCollection <ColumnValuePair> result = request.Results.Cast <ColumnValuePair>();

                result.Add("Field", EColumn.Visible, z => z.Field, z => z.ColumnColour);
                result.Add("Value", EColumn.Visible, z => z.Value, z => z.Colour);
            }
コード例 #5
0
 /// <summary>
 /// Builds collection of columns.
 /// </summary>
 /// <param name="columns"></param>
 private void _BuildColumnsCollection(ColumnCollection columns)
 {
     columns.Clear();
     foreach (Column column in _columns)
     {
         if (column.FieldName.Equals("Capacities") || column.FieldName.Equals("CustomOrderProperties"))
         {
             Collection <Column> dynamicColumns = column.FieldName.Equals("Capacities") ?
                                                  _GetDynamicCapacitiesColumns(column.ReadOnly) :
                                                  _GetDynamicCustomOrderColumns(column.ReadOnly);
             foreach (Column dynamicColumn in dynamicColumns)
             {
                 if (column.CellEditor != null)
                 {
                     dynamicColumn.CellEditor = column.CellEditor;
                 }
                 dynamicColumn.Width = column.Width;
                 columns.Add(dynamicColumn);
             }
         }
         else if (column.FieldName.Equals("AddressFields"))
         {
             Collection <Column> dynamicColumns = _GetDynamicAddressColumns(column.ReadOnly);
             foreach (Column dynamicColumn in dynamicColumns)
             {
                 columns.Add(dynamicColumn);
             }
         }
         else
         {
             columns.Add(column);
         }
     }
 }
コード例 #6
0
        public bool Upgrade()
        {
            ColumnCollection oldcolumns = null;
            BusinessObject   BO         = null;
            object           dsid       = SqlHelper.ExecuteScalar(_metastring, "select DataSourceID from uap_report where id='" + _reportid + "'");

            if (dsid != null)
            {
                oldcolumns = ((QueryFunction)BO.Functions[0]).QuerySettings[0].QueryResultTable.Columns;
                //((QueryFunction)BO.Functions[0]).QuerySettings[0].QueryResultTable.Columns=new ColumnCollection();
            }
            else
            {
                //new bo
            }

            ColumnCollection newcolumns = ((QueryFunction)BO.Functions[0]).QuerySettings[0].QueryResultTable.Columns;
            //获取老报表数据,考虑列的顺序
            SqlDataReader reader = SqlHelper.ExecuteReader(_datastring, "select ,, from rpt order by orderid");

            while (reader.Read())
            {
                string      columnname = reader["ColumnName"].ToString();
                TableColumn column     = AlreadyInColumns(columnname, oldcolumns);
                if (column != null)
                {
                    newcolumns.Add(column);
                }
                else//不存在则加进去
                {
                    DataTypeEnum dt   = GetDataType();
                    string       desc = null;
                    column = new TableColumn(columnname, dt, desc);
                    newcolumns.Add(column);
                }
            }
            ConfigureServiceProxy c = new ConfigureServiceProxy();

            c.UpdateBusinessObject(BO);

            UpgradeReport ur = new UpgradeReport();

            ur.DataSourceID = BO.MetaID;


            //创建BusinessObject对象,并调用Save方法
            //创建Report对象,并调用Save方法
            //reportengine
            //Report report=reportengine.DesignReport()
            //reportengine.UpgradeSave(report,ref commonxml,ref cnxml,ref twxml,ref enxml);
            //if rpt_id在meta库中UAP_Report表不存在
            //BusinessObject BO = new BusinessObject();
            //else rpt_id在meta库中UAP_Report表存在
            //ConfigureServiceProxy proxy =new ConfigureServiceProxy();
            //proxy.GetBusinessObject()

            ur.Save();
            return(true);
        }
コード例 #7
0
        private ColumnCollection CollectionWith2Columns()
        {
            ColumnCollection cc = new ColumnCollection();

            cc.Add(new SortColumn("Column1", typeof(System.String)));
            cc.Add(new SortColumn("Column2", System.ComponentModel.ListSortDirection.Ascending, typeof(System.String), true));
            return(cc);
        }
コード例 #8
0
        ITableConfiguration <TModel> ITableConfiguration <TModel> .AddColumn <TColumn>(
            Expression <Func <TModel, TColumn> > columnDefinition,
            Action <IFormatableColumnConfiguration <TModel, TColumn> > columnConfig)
        {
            var config = new TextColumn <TModel, TColumn>(columnDefinition);

            columnConfig.ExecuteIfNotNull(config);
            _columns.Add(config);
            return(this);
        }
コード例 #9
0
ファイル: Item.cs プロジェクト: vaginessa/NetworkADB
        public Item(byte[][] pathData, string root, string path, string name, IFileObject fo, IFolderObject parrent, IShellView sv)
        {
            base.ShellView = sv;
            this.parrent   = parrent;
            columns        = new ColumnCollection();
            columns.Add(ColName);
            columns.Add(ColAttr);
            columns.Add(ColPerm1);
            columns.Add(ColPerm2);
            columns.Add(ColFileSize);
            columns.Add(ColDate);
            columns.Add(ColTime);
            columns.Add(ColLinkTo);

            this.root = root;
            this.path = path;
            this.name = name;
            this.fo   = fo;
            base.SetPath(pathData);
            if (string.IsNullOrEmpty(root))
            {
                if (string.IsNullOrEmpty(path))
                {
                    base.SetPath(string.Format("{0}", name));
                }
                else
                {
                    base.SetPath(string.Format("{0}{1}{2}", path, FD, name));
                }
            }
            else
            {
                base.SetPath(string.Format("{0}{1}{2}{3}{4}", root, FD, path, FD, name));
            }
        }
コード例 #10
0
        public Folder(byte[][] pathData, IdList idlist, string root, string path, FolderAttributes attrs, IFileObject fo, IShellView sv, IFolderObject parrent)
        {
            this.parrent = parrent;
            columns      = new ColumnCollection();
            columns.Add(ColName);
            columns.Add(ColAttr);
            columns.Add(ColPerm1);
            columns.Add(ColPerm2);
            columns.Add(ColFileSize);
            columns.Add(ColDate);
            columns.Add(ColTime);
            columns.Add(ColLinkTo);

            base.ShellView = sv;
            this.attrs     = attrs;
            this.root      = root;
            this.path      = path;
            this.fo        = fo;

            if (string.IsNullOrEmpty(root))
            {
                base.SetPath(string.Format("{0}", path));
            }
            else
            {
                base.SetPath(string.Format("{0}{1}{2}", root, FD, path));
            }

            base.SetPath(pathData);
            base.SetIdList(idlist);
        }
コード例 #11
0
        public override void Interpret(Context context)
        {
            Regex           regex   = new Regex(InputPattern, RegexOptions.Singleline);
            MatchCollection matches = regex.Matches(context.Input);

            foreach (Match match in matches)
            {
                string           columnOutput    = "";
                string           columnInput     = match.Groups["column"].Value;
                ColumnCollection columns         = ((Table)Parameter).Columns;
                ColumnCollection filteredColumns = new ColumnCollection();
                foreach (Column column in columns)
                {
                    if (IsValidColumn(column, match.Groups["selection"].Value.Trim()))
                    {
                        filteredColumns.Add(column);
                    }
                }
                foreach (Column column in filteredColumns)
                {
                    string columnTemporaryText = columnInput;
                    RunExpressionsReplace(column, filteredColumns, ref columnTemporaryText);
                    columnOutput += columnTemporaryText;
                }
                string escapedString = Regex.Escape(match.Value);
                context.Output = Regex.Replace(context.Input, escapedString, columnOutput);
                context.Input  = context.Output;
            }
        }
コード例 #12
0
        public ColumnCollection GetColumns()
        {
            ColumnCollection columns   = new ColumnCollection();
            ISqlScript       sqlScript = SqlParserService.Parse(_select);

            if (sqlScript.Statements != null && sqlScript.Statements.Count > 0)
            {
                ISqlStatement statement = sqlScript.Statements[0];
                if (statement is ISelectStatement)
                {
                    ISelectStatement selectStatement = statement as ISelectStatement;
                    if (selectStatement.QueryExpression != null && selectStatement.QueryExpression is ISelectExpression)
                    {
                        ISelectExpression selectExpression = selectStatement.QueryExpression as ISelectExpression;
                        for (int i = 0; i < selectExpression.SelectList.Count; i++)
                        {
                            SelectColumn selectColumn = selectExpression.SelectList[i];
                            Column       column       = _table[selectColumn.Name];
                            if (column != null)
                            {
                                columns.Add(column);
                            }
                        }
                    }
                }
            }
            return(columns);
        }
コード例 #13
0
        private ColumnCollection CollectSortColumns()
        {
            ColumnCollection cl = new ColumnCollection();

            if (this.nodeSorting.Nodes.Count > 0)
            {
                SortColumn     sortColumn;
                AbstractColumn abstrCol;

                foreach (SortColumnNode sortNode in this.nodeSorting.Nodes)
                {
                    abstrCol = this.reportModel.ReportSettings.AvailableFieldsCollection.Find(sortNode.Text);

                    if (abstrCol != null)
                    {
                        sortColumn = new SortColumn(sortNode.FieldName,
                                                    sortNode.SortDirection,
                                                    abstrCol.DataType, true);
                    }
                    else
                    {
                        sortColumn = new SortColumn(sortNode.Text,
                                                    sortNode.SortDirection,
                                                    typeof(System.String), true);
                    }
                    cl.Add(sortColumn);
                }
            }
            return(cl);
        }
コード例 #14
0
        private static ColumnCollection CreateColumns(DataTable data)
        {
            var columns = new ColumnCollection();

            foreach (DataRow row in data.Rows)
            {
                var column = new Column
                {
                    Schema = (string)row["TABLE_SCHEMA"],
                    //SchemaDescription = (string)row["SchemaDescription"],
                    Table           = GetCleanTableName((string)row["TABLE_NAME"]),
                    Name            = (string)row["COLUMN_NAME"],
                    DataType        = (string)row["DATA_TYPE"],
                    IsIdentity      = (int)row["IS_IDENTITY"] == 1,
                    IsRequired      = (string)row["IS_NULLABLE"] == "NO",
                    OrdinalPosition = (int)row["ORDINAL_POSITION"]
                };

                if (!row.IsNull("CHARACTER_MAXIMUM_LENGTH"))
                {
                    var max = (int)row["CHARACTER_MAXIMUM_LENGTH"];
                    if (max > 0)
                    {
                        column.MaximumLength = max;
                    }
                }

                columns.Add(column);
            }

            return(columns);
        }
コード例 #15
0
        protected override void InitGridColumn()
        {
            //GridPanel1.ColumnModel.Columns.Clear();
            ColumnCollection columns = GridPanel1.ColumnModel.Columns;
            ColumnBase       col     = new RowNumbererColumn();

            //columns.Add(col);
            col = new NumberColumn()
            {
                Header = "排序", DataIndex = "orderID", Width = 50, Fixed = true
            };
            (col as NumberColumn).Format = "0";
            col.Editor.Add(new NumberField());
            columns.Add(col);
            col = new Column()
            {
                Header = "代码", DataIndex = "ProgCode", Width = 80, Fixed = true
            };
            col.Editor.Add(new TextField());
            columns.Add(col);
            col = new Column()
            {
                Header = "名称", DataIndex = "ProgName"
            };
            col.Editor.Add(new TextField());
            columns.Add(col);
            col = new Column()
            {
                Header = "页面", DataIndex = "ProgClass"
            };
            col.Editor.Add(new TextField());
            columns.Add(col);
            col = new Column()
            {
                Header = "小图标", DataIndex = "ProgIcon1", Width = 50, Fixed = true
            };
            col.Editor.Add(new TextField());
            columns.Add(col);
            col = new Column()
            {
                Header = "大图标", DataIndex = "ProgIcon2", Width = 50, Fixed = true
            };
            col.Editor.Add(new TextField());
            columns.Add(col);
            col = new Column()
            {
                Header = "分类", DataIndex = "IsCore", Width = 40, Fixed = true
            };
            col.Editor.Add(new TextField());
            columns.Add(col);
            col = new Column()
            {
                Header = "组", DataIndex = "IsGroup", Width = 30, Fixed = true
            };
            col.Editor.Add(new TextField());
            columns.Add(col);
        }
コード例 #16
0
ファイル: MyItem.cs プロジェクト: vaginessa/NetworkADB
 public MyItem(byte[][] pathData, int n)
 {
     columns = new ColumnCollection();
     columns.Add(ColName);
     this.n = n;
     base.SetPath(n.ToString());
     base.SetPath(pathData);
 }
コード例 #17
0
        static KeyItem()
        {
            columns = new ColumnCollection();
            columns.Add(ColName);
            columns.Add(ColType);
            columns.Add(ColValue);
            //columns.Add(ColDet);

            /*
             * columns.Add(ColDet1);
             * columns.Add(ColDet2);
             * columns.Add(ColDet3);
             * columns.Add(ColDet4);
             */
            columns.DefaultDisplayColumn = ColName;
            columns.DefaultSortColumn    = ColName;
        }
コード例 #18
0
    /// <summary>
    /// ColumnName is also binding property name
    /// </summary>
    /// <param name="columnName"></param>
    public void AddColumn(string columnName)
    {
        DataGridTextColumn column = new DataGridTextColumn();

        column.Header  = columnName;
        column.Binding = new Binding(columnName);
        ColumnCollection.Add(column);
    }
コード例 #19
0
        private static void AddColumnsInternal(ColumnCollection columns, Type itemType, IPageableList owner, string prefix = null, string tableName = null)
        {
            var props = itemType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            foreach (var prop in props)
            {
                if (prop.Name == Constants.BaseInfoPropertyName) // Add columns from the "base" classes
                {
                    var method = prop.PropertyType.GetMethod("GetProcessDefinition",
                                                             BindingFlags.Static | BindingFlags.Public);

                    var procDefinition = method.Invoke(null, BindingFlags.InvokeMethod, null, null, null);
                    var table = ((ProcessDefinition)procDefinition).TableList.Last().Name;

                    AddColumnsInternal(columns,prop.PropertyType, owner,
                                       string.IsNullOrEmpty(prefix)
                                           ? Constants.BaseInfoPropertyName
                                           : string.Format("{0}.{1}", prefix, Constants.BaseInfoPropertyName), table);
                }

                var display = (from d in prop.GetCustomAttributes(typeof(DisplayAttribute), false) select d).FirstOrDefault();
                var crossRef = (CrossRefFieldAttribute) (from d in prop.GetCustomAttributes(typeof(CrossRefFieldAttribute), false) select d).FirstOrDefault();
                if (display == null || string.IsNullOrEmpty(((DisplayAttribute)display).Name)) continue;
                var column = ColumnFactory.CreateColumn(owner, columns, crossRef);
                column.Header = ((DisplayAttribute) display).Name;
                //ColumnName =
                                    //    (crossRef == null || string.IsNullOrWhiteSpace(crossRef.RefFieldName))
                                    //        ? prop.Name
                                    //        : crossRef.RefFieldName,
                column.ReferenceTableName = (crossRef == null || string.IsNullOrWhiteSpace(crossRef.ReferenceTableName))
                                                ? string.Empty
                                                : crossRef.ReferenceTableName;
                                    //Width = getWidth(prop),
                column.IsBase = !string.IsNullOrWhiteSpace(prefix);
                column.ColumnName = prop.Name;
                column.Property = prop;
                column.Prefix = prefix;
                column.TableName = tableName;
                column.Width = prop.PropertyType == typeof (string) ? 200 : 50;

                // this cycle is need only to display hyperlink column for field file.
                // search for an item with the equals name, but only at the end + "Url",
                // if found, write AdditionalDataPropertyName item name + "Url"
                foreach (var prop1 in props)
                {
                    if (prop1.Name.EndsWith("Url") && prop1.Name.Remove(prop1.Name.Length - 3, 3) == prop.Name)
                    {
                        column.AdditionalDataPropertyName = prop1.Name;
                        break;
                    }
                }

                columns.Add(column);
            }
            

            //RaisePropertyChanged(() => Columns);

        }
コード例 #20
0
    private Column method_68(int A_0)
    {
        ColumnCollection columns = this.method_67();

        while (columns.Count <= A_0)
        {
            columns.Add(new Column(base.document_0));
        }
        return(columns[A_0]);
    }
コード例 #21
0
 internal void ReadAllColumns <T>(Converter <T, MetaInfoCollection> collectionRetriever, ColumnCollection columns)
     where T : Visualisable
 {
     for (int index = 0; index < this._headers.Length; index++)
     {
         string       header      = this._headers[index];
         int          __closure   = index;
         const string description = "This column represents meta data provided by the user.";
         columns.Add(new Column <T>("Meta\\" + header, EColumn.IsMeta, description, λ => collectionRetriever(λ).Read(__closure), null));
     }
 }
コード例 #22
0
        public void TestAddMethodSimple()
        {
            columns = new ColumnCollection(basicColumns);
            Column newColumn = new Column("TestColumn");

            Assert.IsFalse(columns.Contains(newColumn));

            columns.Add(newColumn);

            Assert.IsTrue(columns.Contains(newColumn));
        }
コード例 #23
0
ファイル: ConditionTest.cs プロジェクト: pyramida/DunaGrid
        public void parseStringTest()
        {
            Condition_Accessor target = new Condition_Accessor(); // TODO: Initialize to an appropriate value
            ColumnCollection grid_columns = new ColumnCollection();
            grid_columns.Add(new TextColumn("Sloupec 1"));
            grid_columns.Add(new TextColumn("Sloupec 2"));
            grid_columns.Add(new NumberColumn("Sloupec 3"));
            grid_columns.Add(new NumberColumn("cislo"));

            grid_columns.Add(new TextColumn("Sloupec like"));

            Check(target, "[Sloupec 1] = 100", grid_columns, grid_columns[0], "100", Operators.equal);
            Check(target, "cislo > 56", grid_columns, grid_columns[3], "56", Operators.greater_than);
            Check(target, "cislo >= '56'", grid_columns, grid_columns[3], "56", Operators.greater_than | Operators.equal);
            Check(target, "[Sloupec 2] LIKE '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "[Sloupec 2] like '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "Sloupec 2 like '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "Sloupec 2 like 'neco = pokus'", grid_columns, grid_columns[1], "neco = pokus", Operators.like);
            Check(target, "Sloupec 1 REGeXp 'neco.*'", grid_columns, grid_columns[0], "neco.*", Operators.regexp);

            Check(target, "[Sloupec like] like '160%'", grid_columns, grid_columns[4], "160%", Operators.like);
        }
コード例 #24
0
        public void TestAddColumnWTable(Column column, Table table)
        {
            columns = new ColumnCollection();
            Column testColumn = new Column(column.ColumnName);

            Assert.AreEqual(column, testColumn);

            columns.Add(column, table);

            Assert.IsTrue(columns.Contains(column));
            Assert.AreNotEqual(column, testColumn);
            Assert.AreEqual(table, column.Table);
        }
コード例 #25
0
        public void CanValidate()
        {
            var cc = new ColumnCollection();

            Assert.IsNull(cc.Validate(true));
            Assert.IsNull(cc.Validate(false));

            // add invalid column
            cc.Add(new Column {
                ClrType = typeof(string), DbType = "nvarchar"
            });
            Assert.IsNull(cc.Validate());
            Assert.IsNotNull(cc.Validate(true));
        }
コード例 #26
0
ファイル: ConditionTest.cs プロジェクト: pyramida/DunaGrid
        public void parseStringTest()
        {
            Condition_Accessor target       = new Condition_Accessor(); // TODO: Initialize to an appropriate value
            ColumnCollection   grid_columns = new ColumnCollection();

            grid_columns.Add(new TextColumn("Sloupec 1"));
            grid_columns.Add(new TextColumn("Sloupec 2"));
            grid_columns.Add(new NumberColumn("Sloupec 3"));
            grid_columns.Add(new NumberColumn("cislo"));

            grid_columns.Add(new TextColumn("Sloupec like"));

            Check(target, "[Sloupec 1] = 100", grid_columns, grid_columns[0], "100", Operators.equal);
            Check(target, "cislo > 56", grid_columns, grid_columns[3], "56", Operators.greater_than);
            Check(target, "cislo >= '56'", grid_columns, grid_columns[3], "56", Operators.greater_than | Operators.equal);
            Check(target, "[Sloupec 2] LIKE '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "[Sloupec 2] like '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "Sloupec 2 like '160%'", grid_columns, grid_columns[1], "160%", Operators.like);
            Check(target, "Sloupec 2 like 'neco = pokus'", grid_columns, grid_columns[1], "neco = pokus", Operators.like);
            Check(target, "Sloupec 1 REGeXp 'neco.*'", grid_columns, grid_columns[0], "neco.*", Operators.regexp);

            Check(target, "[Sloupec like] like '160%'", grid_columns, grid_columns[4], "160%", Operators.like);
        }
コード例 #27
0
        public void GetColumnsFromDefaultLayout(string processSystemName, Action<ColumnCollection> callback)
        {
            var filter = GetLayoutFilter(processSystemName);

            TheDynamicTypeManager.BeginGetList<ILayoutList<ILayoutInfo>>(Constants.LayoutProcessName, (o, r) =>
                {
                    if (r.Error != null)
                    {
                        return;
                    }

                    var defaultLayout = (ILayoutInfo)r.Object[0];

                    var layoutViewModel = new NewLayoutViewModel
                    {
                        Id = defaultLayout.Id,
                        AccountId = defaultLayout.AccountId,
                        LayoutString = defaultLayout.LayoutDefinition,
                        IsAdminLayout = defaultLayout.IsAdminLayout ?? false,
                        IsDefault = defaultLayout.IsDefault ?? false,
                        Name = defaultLayout.Name,
                    };

                    layoutViewModel.Parse(layoutViewModel.LayoutString);

                    var type = TheDynamicTypeManager.GetListType(processSystemName).BaseType.GetGenericArguments()[1];

                    var columnCollection = new ColumnCollection();

                    for (int i = 0; i < layoutViewModel.LayoutColumns.Count; i++)
                    {
                        var layoutColumn = layoutViewModel.LayoutColumns[i];
                        var property = type.GetProperty(layoutColumn.SystemName);

                        var column = new ColumnItem(null, null)
                        {
                            Header = layoutColumn.Header,
                            ColumnName = layoutColumn.SystemName,
                            Width = layoutColumn.Width.HasValue ? layoutColumn.Width.Value : 0,
                            Order = i,
                            Property = property
                        };

                        columnCollection.Add(column);
                    }

                    callback(columnCollection);

                }, filterExpression: filter.ToJSON(), pageSize: 1);
        }
コード例 #28
0
        /// <summary>
        /// Builds collection of columns.
        /// </summary>
        /// <param name="parametersCount">Parameters count.</param>
        /// <param name="readedColumns">Readed columns.</param>
        /// <param name="columns">Colums.</param>
        private void _BuildColumnsCollection(int parametersCount,
                                             ArrayList readedColumns,
                                             ColumnCollection columns)
        {
            Debug.Assert(null != readedColumns);
            Debug.Assert(null != columns);

            columns.Clear();

            foreach (Column column in readedColumns)
            {
                if (!column.FieldName.Equals(DYNAMIC_FIELDS_ALIAS))
                {
                    columns.Add(column);
                }
                else
                {
                    string parameterColumnTitleFormat =
                        App.Current.FindString("ParameterColumnHeaderFormat");

                    for (int index = 0; index < parametersCount; ++index)
                    {
                        var col = new Column();
                        col.FieldName = _GetDynamicFieldName(index);
                        col.Title     = string.Format(parameterColumnTitleFormat,
                                                      (0 == index) ? "" : (index + 1).ToString());
                        col.CellContentTemplate = column.CellContentTemplate;
                        col.CellEditor          = column.CellEditor;
                        col.Width    = column.Width;
                        col.MinWidth = column.MinWidth;
                        col.MaxWidth = column.MaxWidth;
                        col.CellValidationRules.Add(new ParameterValidationRule());
                        columns.Add(col);
                    }
                }
            }
        }
コード例 #29
0
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                Assert.IsTrue(value != null && value is IEnumerable <string>);

                var cols = new ColumnCollection();
                var list = value as IEnumerable <string>;

                foreach (var i in list)
                {
                    cols.Add(new DataGridColumn {
                        Title = i, PropertyName = i
                    });
                }

                return(cols);
            }
コード例 #30
0
        public MainWindowVm()
        {
            ResourceSatellites.Add(new ResourceSatellite("Тип 1", 10, 20)
            {
                ResourceSystems = new ObservableCollection <ResourceSystem>()
                {
                    new ResourceSystem("Система 1", 10, 13),
                    new ResourceSystem("Система 2", 13, 16),
                    new ResourceSystem("Система 3", 16, 20)
                }
            });

            ResourceSatellites.Add(new ResourceSatellite("Тип 2", 777, 999)
            {
                ResourceSystems = new ObservableCollection <ResourceSystem>()
                {
                    new ResourceSystem("Система 1", 777, 888),
                    new ResourceSystem("Система 3", 889, 999)
                }
            });

            ColumnCollection.Add(new DataGridTextColumn()
            {
                Header = "Тип ресурса", Binding = new Binding("ResourceType")
            });
            ColumnCollection.Add(new DataGridTextColumn()
            {
                Header = "Мин", Binding = new Binding("MinValue")
            });
            ColumnCollection.Add(new DataGridTextColumn()
            {
                Header = "Макс", Binding = new Binding("MaxValue")
            });

            //var systList = new List<ResourceSystem> { "Система 1", "Система 2", "Система 3", "Система 4" };

            //foreach (var syst in systList)
            //{
            //    ColumnCollection.Add(new DataGridTextColumn()
            //    { Header = syst, Binding = new Binding("ResourceSystems")
            //        {Converter = new SystemConverter(), ConverterParameter = syst}
            //    });
            //}
        }
コード例 #31
0
        public void SetColumns()
        {
            ColumnCollection.Add(new DataGridTextColumn()
            {
                Header  = "Nome",
                Binding = new Binding("Nome")
            });

            foreach (var criterio in Items.First().CriterioAlternativa)
            {
                ColumnCollection.Add(new DataGridTemplateColumn()
                {
                    Header       = criterio.Criterio.Nome,
                    CellTemplate = new DataTemplate()
                    {
                        VisualTree = CreateElement(criterio.Criterio.Nome)
                    }
                });
            }
        }
コード例 #32
0
        public ColumnCollection GetColumns()
        {
            ColumnCollection temp = new ColumnCollection();

            DataTable dt = (DataTable)data_source.DataSource;

            int i = 0;

            foreach (DataColumn dc in dt.Columns)
            {
                IColumn col = ColumnTypeDelegator.getByType(dc.DataType);
                col.HeadText = dc.ColumnName;
                col.Width = 100;
                col.DataSourceColumnIndex = i;
                temp.Add(col);
                i++;
            }

            return temp;
        }
コード例 #33
0
        public ColumnCollection GetColumns()
        {
            ColumnCollection temp = new ColumnCollection();

            DataTable dt = (DataTable)data_source.DataSource;

            int i = 0;

            foreach (DataColumn dc in dt.Columns)
            {
                IColumn col = ColumnTypeDelegator.getByType(dc.DataType);
                col.HeadText = dc.ColumnName;
                col.Width    = 100;
                col.DataSourceColumnIndex = i;
                temp.Add(col);
                i++;
            }

            return(temp);
        }
コード例 #34
0
        public void GetXColumns(CustomColumnRequest request)
        {
            ColumnCollection <Association <T> > results = request.Results.Cast <Association <T> >();

            // Add association as-is (don't include a folder before it!)
            results.AddRange(ColumnManager.AddSubObject <Association <T> >(EColumn.Advanced, EColumn.Visible, request.Core, "", z => z.Associated, typeof(T)));

            // Add extra columns from original request
            if (this.OriginalRequest?.ExtraColumns != null)
            {
                for (int n = 0; n < this.OriginalRequest.ExtraColumns.Count; ++n)
                {
                    int closure = n;
                    Tuple <string, string> c = this.OriginalRequest.ExtraColumns[n];

                    results.Add(new Column <Association <T> >(c.Item1, EColumn.Visible, c.Item2, z => z.GetExtraColumnValue(closure), z => Color.Blue));
                }
            }

            request.NoAutomaticColumns = true; // Else conflicts
        }
コード例 #35
0
        /// <summary>
        /// IMPLEMENTS IVisualisable
        /// </summary>
        public override void GetXColumns(CustomColumnRequest request)
        {
            ColumnCollection <Cluster> result = request.Results.Cast <Cluster>();
            Core core = request.Core;

            result.Add("Assignments\\As peaks", EColumn.None, λ => λ.Assignments.Peaks.ToArray());
            result.Add("Assignments\\As scores", EColumn.Advanced, λ => λ.Assignments.Scores.ToArray());

            foreach (GroupInfo group in core.Groups)
            {
                GroupInfo closure = group;
                result.Add(
                    "Assignments\\For " + group.DisplayName,
                    EColumn.None,
                    λ => λ.Assignments.List.Where(z => z.Vector.Group == closure).Select(z => z.Cluster).ToArray(),
                    z => closure.Colour);
            }

            foreach (UserFlag flag in core.Options.UserFlags)
            {
                UserFlag closure = flag;
                result.Add(
                    "Flags\\" + flag,
                    EColumn.Advanced,
                    λ => λ.CommentFlags.ContainsKey(closure) ? λ.CommentFlags[closure] : 0,
                    z => closure.Colour);
            }

            result.Add("Flags\\Summary", EColumn.None, λ => λ.CommentFlags.Select(z => z.Key + " = " + z.Value), z => z.CommentFlags.Count != 1 ? Color.Black : z.CommentFlags.Keys.First().Colour);

            foreach (ConfigurationStatistic stat in core.Statistics.WhereEnabled())
            {
                ConfigurationStatistic closure = stat;
                result.Add("Average Statistic\\" + closure, EColumn.IsStatistic, λ => λ.Statistics.GetOrNan(closure));
            }

            foreach (string stat in core.GetClusterStatistics()) // TODO: No!
            {
                string closure = stat;
                result.Add("Cluster statistic\\" + closure, EColumn.IsStatistic, λ => λ.ClusterStatistics.GetOrNan(closure));
            }
        }
コード例 #36
0
ファイル: Table.cs プロジェクト: nHydrate/nHydrate
 public IEnumerable<Column> GetColumnNotInRelationships()
 {
     try
     {
         var inRelations = this.GetColumnInRelationships();
         var retval = new ColumnCollection(this.Root);
         foreach (var c in this.GetColumns())
         {
             if (!inRelations.Contains(c))
                 retval.Add(c);
         }
         return retval.OrderBy(x => x.Name);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
コード例 #37
0
ファイル: Table.cs プロジェクト: nHydrate/nHydrate
        /// <summary>
        /// This gets all columns in this class NOT in a base class
        /// </summary>
        /// <returns></returns>
        public ColumnCollection GetColumnsNotInBase()
        {
            try
            {
                var nameList = new List<string>();
                var fullList = GetColumnsFullHierarchy(false);

                var currentList = new List<Column>();
                foreach (var c in this.GetColumns())
                    currentList.Add(c);

                var delList = new List<Column>();
                foreach (var c in currentList)
                {
                    if (fullList[c.Name] != null)
                    {
                        delList.Add(c);
                    }
                }

                foreach (var c in delList)
                {
                    currentList.Remove(c);
                }

                var retval = new ColumnCollection(this.Root);
                foreach (var c in currentList)
                    retval.Add(c);
                return retval;

            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #38
0
ファイル: Table.cs プロジェクト: nHydrate/nHydrate
 public ColumnCollection GetColumnInRelationships()
 {
     var retval = new ColumnCollection(this.Root);
     foreach (var r in ((ModelRoot)this.Root).Database.Relations.ToList())
     {
         if (r.ParentTableRef.Object == this)
         {
             foreach (var cr in r.ColumnRelationships.ToList())
             {
                 var column = cr.ParentColumnRef.Object as Column;
                 if (!retval.Contains(column))
                     retval.Add(column);
             }
         }
         else if (r.ChildTableRef.Object == this)
         {
             foreach (var cr in r.ColumnRelationships.ToList())
             {
                 var column = cr.ChildColumnRef.Object as Column;
                 if (!retval.Contains(column))
                     retval.Add(column);
             }
         }
     }
     return retval;
 }
コード例 #39
0
ファイル: C1FlexGrid.cs プロジェクト: mdjabirov/C1Decompiled
 private static ColumnCollection CloneColumns(GridPanel panel)
 {
     ColumnCollection columns = new ColumnCollection(panel, (int) panel.Columns.DefaultSize);
     columns.Indent = panel.Columns.Indent;
     using (columns.DeferNotifications())
     {
         foreach (Column column in panel.Columns)
         {
             columns.Add(column);
             column.List = panel.Columns;
         }
     }
     return columns;
 }
コード例 #40
0
ファイル: Table.cs プロジェクト: nHydrate/nHydrate
        /// <summary>
        /// This gets all columns from this and all base classes
        /// </summary>
        /// <returns></returns>
        public ColumnCollection GetColumnsFullHierarchy(bool includeCurrent)
        {
            try
            {
                var nameList = new List<string>();
                var retval = new ColumnCollection(this.Root);

                var t = this;
                if (!includeCurrent) t = t.ParentTable;
                while (t != null)
                {
                    foreach (var r in t.Columns.ToList())
                    {
                        var c = r.Object as Column;
                        if (!nameList.Contains(c.Name.ToLower()))
                        {
                            nameList.Add(c.Name.ToLower());
                            retval.Add(c);
                        }
                    }
                    t = t.ParentTable;
                }
                return retval;

            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #41
0
    public static void UpdateColumnsOnItemsPropertiesChanged( 
      DataGridControl dataGridControl, 
      ColumnCollection columns,
      bool autoCreateForeignKeyConfigurations,
      NotifyCollectionChangedEventArgs e,
      DataGridItemPropertyCollection itemProperties )
    {
      if( dataGridControl == null )
        return;

      switch( e.Action )
      {
        case NotifyCollectionChangedAction.Add:
          {
            foreach( DataGridItemPropertyBase itemProperty in e.NewItems )
            {
              string name = itemProperty.Name;

              if( columns[ name ] == null )
              {
                Column column = ItemsSourceHelper.CreateColumnFromItemsSourceField(
                  dataGridControl, dataGridControl.DefaultCellEditors,
                  ItemsSourceHelper.CreateFieldFromDataGridItemProperty( itemProperty ),
                  autoCreateForeignKeyConfigurations );

                if( column != null )
                {
                  columns.Add( column );
                  ItemsSourceHelper.ApplySettingsRepositoryToColumn( column );
                }
              }
            }
          }

          break;

        case NotifyCollectionChangedAction.Remove:
          {
            foreach( DataGridItemPropertyBase itemProperty in e.OldItems )
            {
              string name = itemProperty.Name;
              Column column = columns[ name ] as Column;

              if( ( column != null ) && ( column.IsAutoCreated ) )
              {
                columns.Remove( column );
              }
            }

            break;
          }

        case NotifyCollectionChangedAction.Replace:
          {
            foreach( DataGridItemPropertyBase itemProperty in e.OldItems )
            {
              string name = itemProperty.Name;
              Column column = columns[ name ] as Column;

              if( ( column != null ) && ( column.IsAutoCreated ) )
              {
                columns.Remove( column );
              }
            }

            foreach( DataGridItemPropertyBase itemProperty in e.NewItems )
            {
              string name = itemProperty.Name;

              if( columns[ name ] == null )
              {
                Column column = ItemsSourceHelper.CreateColumnFromItemsSourceField(
                  dataGridControl, dataGridControl.DefaultCellEditors,
                  ItemsSourceHelper.CreateFieldFromDataGridItemProperty( itemProperty ),
                  autoCreateForeignKeyConfigurations );

                if( column != null )
                {
                  columns.Add( column );
                  ItemsSourceHelper.ApplySettingsRepositoryToColumn( column );
                }
              }
            }

            break;
          }

        case NotifyCollectionChangedAction.Reset:
          {
            for( int i = columns.Count - 1; i >= 0; i-- )
            {
              Column dataColumn = columns[ i ] as Column;

              if( ( dataColumn != null ) && ( dataColumn.IsAutoCreated ) )
              {
                columns.Remove( dataColumn );
              }
            }

            foreach( DataGridItemPropertyBase itemProperty in itemProperties )
            {
              string name = itemProperty.Name;

              if( columns[ name ] == null )
              {
                Column column = ItemsSourceHelper.CreateColumnFromItemsSourceField(
                  dataGridControl, dataGridControl.DefaultCellEditors,
                  ItemsSourceHelper.CreateFieldFromDataGridItemProperty( itemProperty ),
                  autoCreateForeignKeyConfigurations );

                if( column != null )
                {
                  columns.Add( column );
                  ItemsSourceHelper.ApplySettingsRepositoryToColumn( column );
                }
              }
            }

            break;
          }

        //case NotifyCollectionChangedAction.Move:
        default:
          break;

      }
    }
コード例 #42
0
ファイル: ColumnsExtensions.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Adds the columns internal.
        /// </summary>
        /// <param name="columns">The columns.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <param name="prefix">The prefix.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="forFilter">if set to <c>true</c> [for filter].</param>
        /// <param name="displayColumns">The display columns.</param>
        /// <param name="hiddenProps">The hidden props.</param>
        private static void AddColumnsInternal(ColumnCollection columns, Type itemType, string prefix = null, string tableName = null, bool forFilter = false, string[] displayColumns = null, List<string> hiddenProps = null)
        {
            var props = itemType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            var inheritanceHelperType = itemType.Assembly.GetType(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", itemType.Namespace, Constants.InheritanceHelperClassName));
            if (hiddenProps == null) hiddenProps = new List<string>();
            if (inheritanceHelperType != null)
            {
                var hiddenPropsProp = inheritanceHelperType.GetProperty(Constants.HiddenFieldListMethodName, BindingFlags.Static | BindingFlags.Public);

                if (hiddenPropsProp != null)
                {
                    var value = hiddenPropsProp.GetValue(null, null);
                    if (value != null)
                        hiddenProps.AddRange((List<string>)value);
                }
            }

            foreach (var prop in props)
            {
                if (prop.Name == Constants.BaseInfoPropertyName)
                {
                    var method = prop.PropertyType.GetMethod(Constants.GetProcessDefinitionMethodName, BindingFlags.Static | BindingFlags.Public);

                    var procDefinition = method.Invoke(null, BindingFlags.InvokeMethod, null, null, null);
                    var table = ((ProcessDefinition)procDefinition).TableList.Last().Name;

                    var baseProcessHiddenProps = hiddenProps.ToList();

                    // Hide system fields from base process.
                    if (!baseProcessHiddenProps.Contains(Constants.CurrentStateColumnName))
                        baseProcessHiddenProps.Add(Constants.CurrentStateColumnName);

                    if (!baseProcessHiddenProps.Contains(Constants.DerivedProcessDisplayNameColumnName))
                        baseProcessHiddenProps.Add(Constants.DerivedProcessDisplayNameColumnName);

                    if (!baseProcessHiddenProps.Contains(Constants.VersionNumber))
                        baseProcessHiddenProps.Add(Constants.VersionNumber);

                    if (!baseProcessHiddenProps.Contains(Constants.VersionDate))
                        baseProcessHiddenProps.Add(Constants.VersionDate);

                    AddColumnsInternal(columns, prop.PropertyType, string.IsNullOrEmpty(prefix) ? Constants.BaseInfoPropertyName : string.Format(CultureInfo.InvariantCulture, "{0}.{1}", prefix, Constants.BaseInfoPropertyName), table, forFilter, displayColumns, baseProcessHiddenProps);
                }

                if (hiddenProps.Contains(prop.Name)) continue;

                // for CR filter we need to skip some system fields
                if (forFilter)
                    if (Constants.CurrentStateColumnName.Equals(prop.Name))
                        continue;

                var display = (from d in prop.GetCustomAttributes(typeof(DisplayAttribute), false) select d).FirstOrDefault() as DisplayAttribute;
                var crossRef = (CrossRefFieldAttribute)(from d in prop.GetCustomAttributes(typeof(CrossRefFieldAttribute), false) select d).FirstOrDefault();
                
                if (display == null || string.IsNullOrEmpty(display.Name))
                    continue;
                var column = ColumnFactory.CreateColumn();
                column.Header = display.GetName();
                column.IsGroupable = CanBeGrouped(prop);

                column.ReferenceTableName = (crossRef == null || string.IsNullOrWhiteSpace(crossRef.ReferenceTableName)) ? string.Empty : crossRef.ReferenceTableName;
                
                column.IsBase = !string.IsNullOrWhiteSpace(prefix);
                if (forFilter)
                    column.ColumnName = crossRef != null && !crossRef.AllowMultiple ? prop.Name + "Id" : prop.Name;
                else
                    column.ColumnName = prop.Name;

                if (displayColumns != null)
                    if (!displayColumns.Contains(column.ColumnName))
                        continue;

                column.Property = prop;
                column.Prefix = prefix;
                column.TableName = tableName;
                column.Width = prop.PropertyType == typeof(string) ? 200 : 50;

                columns.Add(column);
            }
        }
コード例 #43
0
ファイル: Table.cs プロジェクト: ChrisMoreton/Test3
			public ColumnCollection Clone()
			{
				ColumnCollection cc = new ColumnCollection();
				foreach (Column c in this)
					cc.Add(c.Clone());
				return cc;
			}
コード例 #44
0
ファイル: ExplorerTree.cs プロジェクト: Rpinski/SharpDevelop
		private ColumnCollection CollectSortColumns()
		{
			ColumnCollection cl = new ColumnCollection();
			if (this.nodeSorting.Nodes.Count > 0) {
				SortColumn sortColumn;
				AbstractColumn abstrCol;
			
				foreach (SortColumnNode sortNode in this.nodeSorting.Nodes) {
				abstrCol = this.reportModel.ReportSettings.AvailableFieldsCollection.Find(sortNode.Text);
					
					if (abstrCol != null) {
						sortColumn = new SortColumn (sortNode.FieldName,
						                     sortNode.SortDirection,
						                     abstrCol.DataType,true);
					} else {
						sortColumn = new SortColumn (sortNode.Text,
						                     sortNode.SortDirection,
						                     typeof(System.String),true);
					}
					cl.Add(sortColumn);
				}
			}
			return cl;
		}
コード例 #45
0
        /// <summary>
        /// Builds collection of columns.
        /// </summary>
        /// <param name="parametersCount">Parameters count.</param>
        /// <param name="readedColumns">Readed columns.</param>
        /// <param name="columns">Colums.</param>
        private void _BuildColumnsCollection(int parametersCount,
                                             ArrayList readedColumns,
                                             ColumnCollection columns)
        {
            Debug.Assert(null != readedColumns);
            Debug.Assert(null != columns);

            columns.Clear();

            foreach (Column column in readedColumns)
            {
                if (!column.FieldName.Equals(DYNAMIC_FIELDS_ALIAS))
                    columns.Add(column);
                else
                {
                    string parameterColumnTitleFormat =
                        App.Current.FindString("ParameterColumnHeaderFormat");

                    for (int index = 0; index < parametersCount; ++index)
                    {
                        var col = new Column();
                        col.FieldName = _GetDynamicFieldName(index);
                        col.Title = string.Format(parameterColumnTitleFormat,
                            (0 == index) ? "" : (index + 1).ToString());
                        col.CellContentTemplate = column.CellContentTemplate;
                        col.CellEditor = column.CellEditor;
                        col.Width = column.Width;
                        col.MinWidth = column.MinWidth;
                        col.MaxWidth = column.MaxWidth;
                        col.CellValidationRules.Add(new ParameterValidationRule());
                        columns.Add(col);
                    }
                }
            }
        }
コード例 #46
0
ファイル: Table.cs プロジェクト: webgrid/WebGrid
        internal void SaveDataStructure()
        {
            // Save cached structure
            if (!CacheDatasourceStructure || HttpRuntime.Cache.Get(CacheKey) != null ||
                Columns.Primarykeys == null || Columns.Primarykeys.Count == 0
                ||  DataSource != null || string.IsNullOrEmpty(m_Grid.ActiveConnectionString))
                return;

            try
            {
                ColumnCollection cacheTable = new ColumnCollection(this);
                Columns.ForEach(delegate(Column column)
                                    {
                                        Column c = column.Duplicate();
                                        cacheTable.Add(c);
                                    });

                if (DataBaseInterface is SqlConnection)
                {
                    object date =
                        Query.ExecuteScalar("SELECT TOP 1 refdate FROM sysobjects ORDER BY refdate DESC",
                                            m_Grid.ActiveConnectionString);
                    if (date is DateTime)
                        HttpRuntime.Cache[
                            string.Format("{0}_dtm", CacheKey)] = ((DateTime)date).Ticks;
                    else if (m_Grid.Debug)
                        m_Grid.m_DebugString.AppendFormat(
                            "Unable to Get 'refdate' value from sysobjects for Table '{0}'", DataSourceId);

                }
                else if (DataBaseInterface is OleDB)
                {
                    OleDbConnection conn = new OleDbConnection(m_Grid.ActiveConnectionString);
                    conn.Open();

                    DataTable schema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    if (schema.Rows.Count > 0)
                    {
                        object date = schema.Select(null, "DATE_MODIFIED DESC")[0]["DATE_MODIFIED"];
                        conn.Close();
                        if (date is DateTime)
                            HttpRuntime.Cache[
                                string.Format("{0}_dtm", CacheKey)] = ((DateTime)date).Ticks;
                        else if (m_Grid.Debug)
                            m_Grid.m_DebugString.AppendFormat(
                                "Unable to Get 'DATE_MODIFIED' value from 'GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null)' for Table '{0}'",
                                DataSourceId);

                    }
                }
                // Hash code for current page (aspx/ascx page). Used for ValidPageHashCode property
                HttpRuntime.Cache[m_Grid.Trace.ClientID + m_Grid.ClientID] = m_Grid.Page.GetType().GetHashCode();
                HttpRuntime.Cache[CacheKey] = cacheTable;
                if (m_Grid.Trace.IsTracing)
                    m_Grid.Trace.Trace("Created cache for datasource '{0}' in grid '{1}'", DataSourceId, m_Grid.ID);
            }
            catch (Exception ex)
            {
                throw new GridException(
                    string.Format(
                        "Unable to Save Grid CacheStructure ({0}). Remove this error by 'CacheGridStructure=false'",
                        m_Grid.ID), ex);
            }
        }
コード例 #47
0
ファイル: Table.cs プロジェクト: webgrid/WebGrid
        /// <summary>
        /// Retrieves the column cache.
        /// </summary>
        internal void RetrieveColumnCache()
        {
            try
            {

                if (GotCache || HttpRuntime.Cache.Get(CacheKey) == null)
                    return;

                ColumnCollection cacheData =
                    (ColumnCollection)
                    HttpRuntime.Cache.Get(CacheKey);
                Columns = new ColumnCollection(this);

                cacheData.ForEach(delegate(Column column)
                                      {
                                          if (column == null)
                                              return;
                                          Columns.Add(column.Duplicate());
                                      });

                if (m_Grid.Trace.IsTracing)
                    m_Grid.Trace.Trace("{0} : Started datasource information from cache object: {1}", m_Grid.ClientID,
                                       CacheKey);

                for (int i = 0; i < Columns.Count; i++) // Clear some values
                {

                    switch (Columns[i].ColumnType)
                    {
                        case ColumnType.Foreignkey:
                            if (((Foreignkey) Columns[i]).Table.Columns.Primarykeys == null)
                            {
                                ((Foreignkey) Columns[i]).Table.m_LoadedTableSchema = false;
                                ((Foreignkey) Columns[i]).Table.m_GotData = false;
                                DataBaseInterface.LoadColumns(((Foreignkey) Columns[i]).Table);
                            }
                            Columns[i].m_ColumnType = ColumnType.Foreignkey;
                            break;
                        case ColumnType.ManyToMany:
                            if (
                                ((ManyToMany) Columns[i]).m_ForeignDataSource.Columns.Primarykeys ==
                                null)
                            {
                                ((ManyToMany) Columns[i]).m_ForeignDataSource.m_LoadedTableSchema = false;
                                DataBaseInterface.LoadColumns(((ManyToMany) Columns[i]).m_ForeignDataSource);
                            }
                            Columns[i].m_ColumnType = ColumnType.ManyToMany;
                            ((ManyToMany) Columns[i]).Clear();
                            ((ManyToMany) Columns[i]).ReLoad = true;
                            break;
                        case ColumnType.GridColumn:
                            Columns[i].m_ColumnType = ColumnType.GridColumn;
                            ((GridColumn) Columns[i]).GridObject = null;
                            break;
                        case ColumnType.ColumnTemplate:
                            Control m_templateContainer =
                                m_Grid.FindControl(string.Format("{0}_{1}", m_Grid.ClientID, Columns[i].ColumnId));
                            if (m_templateContainer != null)
                                ((ColumnTemplate) Columns[i]).DetailTemplateContainer = m_templateContainer;
                            break;
                    }
                    Columns[i].Grid = m_Grid;
                    Columns[i].m_Table = this;
                }

                GotCache = true;

                if (m_Grid.Debug)
                    m_Grid.m_DebugString.AppendFormat(
                        "<b>Cache</b> - Loaded datasource information from cache object : {0}<br/>", CacheKey);
                if (m_Grid.Trace.IsTracing)
                    m_Grid.Trace.Trace("{0} : Finished datasource information from cache object: {1}", m_Grid.ClientID,
                                       CacheKey);
            }
            catch (Exception ee)
            {
                throw new GridException(
                    string.Format("Error loading datasource information from cache object: {0} and DataSourceId: {1}",
                                  CacheKey, DataSourceId), ee);
            }
        }
コード例 #48
0
        public void Columns_WhenAddedToInnerCollection_AddsToColumns()
        {
            var classUnderTest = new DynamicGridViewBehavior();
            var columns = new ColumnCollection();
            classUnderTest.Attach(new RadGridView());

            classUnderTest.Columns = columns;

            //Act 
            columns.Add(new ColumnItem(columns));

            //Assert
            Assert.IsTrue(classUnderTest.Columns.Count == 1);

        } 
コード例 #49
0
ファイル: ColumnsExtensions.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Adds the columns internal.
        /// </summary>
        /// <param name="columnsList">The columns list.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <param name="owner">The owner.</param>
        /// <param name="prefix">The prefix.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="forFilter">if set to <c>true</c> [for filter].</param>
        /// <param name="displayColumns">The display columns.</param>
        /// <param name="columnOrder">The column order.</param>
        /// <param name="hiddenProps">The hidden props.</param>
        private static void AddColumnsInternal(
            ColumnCollection columnsList,
            Type itemType,
            IRefreashable owner,
            string prefix = null,
            string tableName = null,
            bool forFilter = false,
            string[] displayColumns = null,
            IList<string> columnOrder = null,
            List<string> hiddenProps = null)
        {
            var props = itemType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            var inheritanceHelperType = itemType.Assembly.GetType(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", itemType.Namespace, Constants.InheritanceHelperClassName));
            if (hiddenProps == null)
                hiddenProps = new List<string>();

            if (inheritanceHelperType != null)
            {
                var hiddenPropsProp = inheritanceHelperType.GetProperty(Constants.HiddenFieldListMethodName, BindingFlags.Static | BindingFlags.Public);

                if (hiddenPropsProp != null)
                {
                    var value = hiddenPropsProp.GetValue(null, null);
                    if (value != null)
                        hiddenProps.AddRange((List<string>)value);
                }
            }

            foreach (var prop in props)
            {
                if (prop.Name == Constants.BaseInfoPropertyName)
                {
                    AddBaseProcessProperties(columnsList, owner, prefix, forFilter, displayColumns, columnOrder, hiddenProps, prop);
                }

                if (hiddenProps.Contains(prop.Name))
                    continue;

                // for CR filter we need to skip some system fields
                if (forFilter)
                    if (Constants.CurrentStateColumnName.Equals(prop.Name))
                        continue;

                if (Constants.BaseInfoPropertyName.Equals(prefix) && Constants.DerivedProcessColumnName.Equals(prop.Name))
                    continue;

                var display = (from d in prop.GetCustomAttributes(typeof(DisplayAttribute), false) select d).FirstOrDefault() as DisplayAttribute;
                var crossRef = (CrossRefFieldAttribute)(from d in prop.GetCustomAttributes(typeof(CrossRefFieldAttribute), false) select d).FirstOrDefault();

                if (display == null || string.IsNullOrEmpty(display.Name))
                    continue;

                var column = ColumnFactory.CreateColumn(owner, columnsList, crossRef);
                column.Header = display.GetName();
                column.Property = prop;
                column.IsGroupable = column.CanBeGrouped(prop);

                column.ReferenceTableName = (crossRef == null || string.IsNullOrWhiteSpace(crossRef.ReferenceTableName)) ? string.Empty : crossRef.ReferenceTableName;

                column.IsBase = !string.IsNullOrWhiteSpace(prefix);

                if (forFilter)
                    column.ColumnName = crossRef != null && !crossRef.AllowMultiple ? prop.Name + "Id" : prop.Name;
                else
                    column.ColumnName = prop.Name;

                if (displayColumns != null)
                    if (!displayColumns.Contains(column.ColumnName))
                        continue;

                column.Prefix = prefix;
                column.TableName = tableName;

                if (columnOrder != null)
                {
                    var fullColumnName = column.IsBase ? string.Format(CultureInfo.InvariantCulture, "{0}.{1}", column.Prefix, column.ColumnName) : column.ColumnName;
                    if (columnOrder.Contains(fullColumnName))
                        column.DefaultOrder = columnOrder.ToList().IndexOf(fullColumnName);
                    else
                        continue;
                }

                columnsList.Add(column);
            }
        }
コード例 #50
0
ファイル: Table.cs プロジェクト: ChrisMoreton/Test3
		internal void redimTable(int cols, int rows, bool copy,
			int cpCol, int cpRow, bool cpInserted,
			int colsAffected, int rowsAffected, bool undo)
		{
			resetCoveredCells();
			hasHeaderRows = false;

			if (undo) flowChart.UndoManager.onRedimTable(this);

			// remove arrows attached to deleted rows
			if (!cpInserted && (rowsAffected != 0) && (rowsList != null))
			{
				ArrayList arrowsToRemove = new ArrayList();
				for (int i = cpRow; i < cpRow + rowsAffected && i < this.rowsCount; ++i)
				{
					Row r = (Row)this.rowsList[i];
					for (int k = 0; k < r.IncomingArrows.Count; ++k)
						arrowsToRemove.Add(r.IncomingArrows[k]);
					for (int k = 0; k < r.OutgoingArrows.Count; ++k)
						arrowsToRemove.Add(r.OutgoingArrows[k]);
				}
				for (int j = 0; j < arrowsToRemove.Count; ++j)
					flowChart.DeleteObject((ChartObject)arrowsToRemove[j]);
				arrowsToRemove.Clear();
			}

			if (undo) flowChart.UndoManager.onRedimArrowsDeleted(this);

			CellCollection oldData = cells;
			RowCollection oldRowsDsc = rowsList;
			ColumnCollection oldColsDsc = colsList;
			int oldCols = this.columnsCount;
			int oldRows = this.rowsCount;
			bool copyC, copyR;
			copyC = copyR = copy;

			// resize the table
			this.columnsCount = cols;
			this.rowsCount = rows;

			// resize the columns array
			colsList = new ColumnCollection();
			if (this.columnsCount > 0)
			{
				for (int c = 0; c < this.columnsCount; ++c)
				{
					Column col = new Column(this);
					col.width = columnWidth;
					colsList.Add(col);
				}
			}
			else
			{
				copyC = false;
			}

			// resize the rows array
			rowsList = new RowCollection();
			if (this.rowsCount > 0)
			{
				for (int rr = 0; rr < this.rowsCount; ++rr)
				{
					Row row = new Row(this);
					row.Height = rowHeight;
					rowsList.Add(row);
				}
			}
			else
			{
				copyR = false;
			}

			// resize the cells array
			cells = new CellCollection();
			if (this.columnsCount > 0 && this.rowsCount > 0)
			{
				for (int i = 0; i < this.columnsCount * this.rowsCount; ++i)
					cells.Add(new Cell(this));
			}
			else
			{
				copy = false;
			}

			// copy data from the old cells array to the new one
			if (copy && (cells != null) && (oldData != null))
			{
				for (int rr = 0; rr < this.rowsCount; ++rr)
				{
					for (int c = 0; c < this.columnsCount; ++c)
					{
						int cr = rr;
						int cc = c;
						bool cp = true;
						if (cpInserted)
						{
							if (c >= cpCol && c < cpCol + colsAffected) cp = false;
							if (rr >= cpRow && rr < cpRow + rowsAffected) cp = false;
							if (c >= cpCol + colsAffected) cc -= colsAffected;
							if (rr >= cpRow + rowsAffected) cr -= rowsAffected;
						}
						else
						{
							if (c >= cpCol) cc += colsAffected;
							if (rr >= cpRow) cr += rowsAffected;
						}
						if (cp)
						{
							cells[rr * this.columnsCount + c] = oldData[cr * oldCols + cc];
							oldData[cr * oldCols + cc] = null;
						}
						else
							cells[rr * this.columnsCount + c] = new Cell(this);
					}
				}
			}

			if (oldData != null)
			{
				for (int oc = 0; oc < oldData.Count; ++oc)
				{
					if (oldData[oc] != null)
						oldData[oc].freeResources();
				}
			}

			// copy data from the old rows array to the new one
			if (copyR && (rowsList != null) && (oldRowsDsc != null))
			{
				for (int rr = 0; rr < this.rowsCount; ++rr)
				{
					int cr = rr;
					bool cp = true;
					if (cpInserted)
					{
						if (rr >= cpRow && rr < cpRow + rowsAffected) cp = false;
						if (rr >= cpRow + rowsAffected) cr -= rowsAffected;
					}
					else
					{
						if (rr >= cpRow) cr += rowsAffected;
					}
					if (cp)
						rowsList[rr] = oldRowsDsc[cr];
				}
			}

			// copy data from the old columns array to the new one
			if (copyC && (colsList != null) && (oldColsDsc != null))
			{
				for (int c = 0; c < this.columnsCount; ++c)
				{
					int cc = c;
					bool cp = true;
					if (cpInserted)
					{
						if (c >= cpCol && c < cpCol + colsAffected) cp = false;
						if (c >= cpCol + colsAffected) cc -= colsAffected;
					}
					else
					{
						if (c >= cpCol) cc += colsAffected;
					}
					if (cp)
						colsList[c] = oldColsDsc[cc];
				}
			}

			if (rowsAffected > 0)
			{
				updateLinksIndices();
				updateArrowsPos(cpRow);
			}

			if (copy && rowsAffected != 0)
				checkForHeaderRows();

			if (undo) flowChart.UndoManager.onCompleteRedim();
		}
コード例 #51
0
		protected static ColumnCollection CollectFieldsFromModel(ReportModel model){
			if (model == null) {
				throw new ArgumentNullException("model");
			}
			ColumnCollection col = new ColumnCollection();
			
			foreach (BaseSection section in model.SectionCollection){
				for (int i = 0;i < section.Items.Count ;i ++ ) {
					IReportItem item = section.Items[i];
					BaseDataItem baseItem = item as BaseDataItem;
					if (baseItem != null) {
						col.Add(new AbstractColumn(baseItem.ColumnName));
					}
				}
			}
			return col;
		}
コード例 #52
0
    public static void GenerateColumnsFromItemsSourceFields(
      ColumnCollection columns,
      IDictionary<Type, CellEditor> defaultCellEditors,
      Dictionary<string, FieldDescriptor> fields,
      bool autoCreateForeignKeyConfigurations )
    {
      DataGridControl dataGridControl = columns.DataGridControl;

      using( columns.DeferColumnAdditionMessages() )
      {
        foreach( FieldDescriptor field in fields.Values )
        {
          string fieldName = field.Name;
          ColumnBase column = columns[ fieldName ];
          Column dataColumn = column as Column;
          Type dataType = field.DataType;

          if( column == null )
          {
            dataColumn = ItemsSourceHelper.CreateColumnFromItemsSourceField(
              dataGridControl, defaultCellEditors, field, autoCreateForeignKeyConfigurations );

            if( dataColumn != null )
            {
              columns.Add( dataColumn );
              ItemsSourceHelper.ApplySettingsRepositoryToColumn( dataColumn );
            }
          }
          else if( dataColumn != null )
          {
            if( field.ReadOnly )
            {
              if( dataColumn.ReadLocalValue( Column.ReadOnlyProperty ) == DependencyProperty.UnsetValue )
              {
                dataColumn.ReadOnly = field.ReadOnly;
              }
            }

            if( field.OverrideReadOnlyForInsertion )
            {
              if( dataColumn.ReadLocalValue( ColumnBase.OverrideReadOnlyForInsertionProperty ) == DependencyProperty.UnsetValue )
              {
                dataColumn.OverrideReadOnlyForInsertion = field.OverrideReadOnlyForInsertion;
              }
            }

            if( dataColumn.ReadLocalValue( Column.TitleProperty ) == DependencyProperty.UnsetValue )
            {
              dataColumn.Title = field.DisplayName;
            }

            if( dataColumn.ReadLocalValue( Column.CellEditorProperty ) == DependencyProperty.UnsetValue )
            {
              CellEditor cellEditor = null;

              if( defaultCellEditors != null )
              {
                defaultCellEditors.TryGetValue( dataType, out cellEditor );
              }

              if( cellEditor == null )
              {
                object descriptionItemsSource = null;
                object configurationItemsSource = null;
                ForeignKeyConfiguration configuration = dataColumn.ForeignKeyConfiguration;

                if( field.ForeignKeyDescription != null )
                {
                  descriptionItemsSource = field.ForeignKeyDescription.ItemsSource;
                }

                if( configuration != null )
                {
                  configurationItemsSource = configuration.ItemsSource;

                  if( configurationItemsSource == null )
                  {
                    configurationItemsSource = dataColumn.ReadLocalValue( Column.ForeignKeyConfigurationProperty );
                  }
                }

                // A foreign key ItemsSource is set and we can auto-create configuration
                // OR
                // if the foreign key ItemsSource was found in the ForeignKeyConfiguration
                //
                // use the Default ForeignKey CellEditor.
                if( ( ( descriptionItemsSource != null ) && ( autoCreateForeignKeyConfigurations ) )
                    || ( configurationItemsSource != null ) )
                {
                  cellEditor = DefaultCellEditorSelector.ForeignKeyCellEditor;
                }
              }

              if( cellEditor == null )
              {
                cellEditor = DefaultCellEditorSelector.SelectCellEditor( dataType );
              }

              dataColumn.CellEditor = cellEditor;
            }

            if( ( field.ForeignKeyDescription != null )
                && ( field.ForeignKeyDescription.ItemsSource != null )
                && ( autoCreateForeignKeyConfigurations ) )
            {
              // Update the ForeignKeyConfiguration from the ForeignKeyDescription
              // found on the FieldDescriptor
              ForeignKeyConfiguration.SynchronizeForeignKeyConfigurationFromForeignKeyDescription(
                dataColumn,
                field.ForeignKeyDescription,
                autoCreateForeignKeyConfigurations );
            }

            // Disable warning for DisplayMemberBinding when internaly used
#pragma warning disable 618

            if( dataColumn.DisplayMemberBinding == null )
            {
              dataColumn.DisplayMemberBinding = ItemsSourceHelper.CreateDefaultBinding(
                false, field.Name, field,
                false, ( dataColumn.ReadOnly && !dataColumn.OverrideReadOnlyForInsertion ), dataType );

              //mark the Column's Binding as AutoCreated.
              dataColumn.IsBindingAutoCreated = true;
              dataColumn.IsBoundToDataGridUnboundItemProperty = field.IsDataGridUnboundItemProperty;
            }

#pragma warning restore 618
          }
        }
      } //end using
    }
コード例 #53
0
ファイル: ColumnsExtensions.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Adds the display list columns.
        /// </summary>
        /// <param name="columns">The columns.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <param name="owner">The owner.</param>
        public static void AddDisplayListColumns(this ColumnCollection columns, Type itemType, IPageableList owner)
        {
            if (itemType == null)
                return;

            if (columns == null)
                return;

            var columnOut = new ColumnCollection();

            var props = itemType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            foreach (var prop in props)
            {
                if (prop.Name.Equals("DLOrderId"))
                    continue;

                var display = (DisplayAttribute)(from d in prop.GetCustomAttributes(typeof(DisplayAttribute), false) select d).FirstOrDefault();
                if (display == null || string.IsNullOrEmpty(display.Name)) continue;

                var column = ColumnFactory.CreateColumn(owner, columnOut);
                column.Header = display.GetName();
                column.ColumnName = prop.Name;
                column.Property = prop;

                var orderId = display.GetOrder() ?? 0;

                column.Order = orderId;
                columnOut.Add(column);
            }

            foreach (var columnItem in columnOut.OrderBy(d => d.Order))
            {
                columns.Add(columnItem);
            }
        }
コード例 #54
0
 /// <summary>
 /// Builds collection of columns.
 /// </summary>
 /// <param name="columns"></param>
 private void _BuildColumnsCollection(ColumnCollection columns)
 {
     columns.Clear();
     foreach (Column column in _columns)
     {
         if (column.FieldName.Equals("Capacities") || column.FieldName.Equals("CustomOrderProperties"))
         {
             Collection<Column> dynamicColumns = column.FieldName.Equals("Capacities") ?
                                                     _GetDynamicCapacitiesColumns(column.ReadOnly) :
                                                     _GetDynamicCustomOrderColumns(column.ReadOnly);
             foreach (Column dynamicColumn in dynamicColumns)
             {
                 if (column.CellEditor != null)
                     dynamicColumn.CellEditor = column.CellEditor;
                 dynamicColumn.Width = column.Width;
                 columns.Add(dynamicColumn);
             }
         }
         else if (column.FieldName.Equals("AddressFields"))
         {
             Collection<Column> dynamicColumns = _GetDynamicAddressColumns(column.ReadOnly);
             foreach (Column dynamicColumn in dynamicColumns)
                 columns.Add(dynamicColumn);
         }
         else
             columns.Add(column);
     }
 }
コード例 #55
0
ファイル: TableComponent.cs プロジェクト: nHydrate/nHydrate
		/// <summary>
		/// Returns the column for this table only (not hierarchy)
		/// </summary>
		/// <returns></returns>
		public IEnumerable<Column> GetColumns()
		{
			try
			{
				var retval = new ColumnCollection(this.Root);
				foreach (Reference r in this.Columns)
				{
					retval.Add((Column)r.Object);
				}
				return retval.OrderBy(x => x.Name);
			}
			catch (Exception ex)
			{
				throw;
			}
		}