Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.DbExplorer.Interfaces/DbTable.cs @ 6377

Last change on this file since 6377 was 6134, checked in by gkronber, 14 years ago

#1471: added plugin for DbExplorer interfaces, deleted .resx files, set svn:ignore properties, and added license header

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using System.Xml;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.DataImporter.DbExplorer.Interfaces {
30  [StorableClass]
31  public class DbTable {
32    private DbTable()
33      : base() {
34      this.columns = new List<DbColumn>();
35      this.informationLoaded = new DateTime(1990, 1, 1);
36    }
37
38    public DbTable(string ownerName, string tableName)
39      : this() {
40      this.ownerName = ownerName;
41      this.tableName = tableName;
42    }
43
44    [Storable]
45    private string ownerName;
46    public string OwnerName {
47      get { return this.ownerName; }
48      set { this.ownerName = value; }
49    }
50
51    [Storable]
52    private string tableName;
53    public string TableName {
54      get { return this.tableName; }
55      set { this.tableName = value; }
56    }
57
58    [Storable]
59    private List<DbColumn> columns;
60    public IEnumerable<DbColumn> Columns {
61      get { return this.columns; }
62    }
63
64    public bool IsSelected {
65      get { return columns.Any(col => col.Selected); }
66    }
67
68    private int affectedRows;
69    public int AffectedRows {
70      get { return this.affectedRows; }
71      set { this.affectedRows = value; }
72    }
73
74    private int totalRows;
75    public int TotalRows {
76      get { return this.totalRows; }
77      set { this.totalRows = value; }
78    }
79
80    private DateTime informationLoaded;
81    public DateTime InformationLoaded {
82      get { return this.informationLoaded; }
83    }
84
85    public void AddColumn(DbColumn column) {
86      this.columns.Add(column);
87    }
88
89    public void ClearSelection() {
90      foreach (DbColumn col in columns) {
91        col.Selected = false;
92        col.FilterColumn = false;
93        col.LikeValue = "";
94      }
95    }
96
97    public void SelectAllColumns() {
98      foreach (DbColumn col in this.columns)
99        col.Selected = true;
100    }
101
102    public int SelectedColumnsCount {
103      get { return this.columns.Count(col => col.Selected); }
104    }
105
106    public IEnumerable<DbColumn> SelectedColumns {
107      get { return this.columns.Where(col => col.Selected); }
108    }
109
110    public IEnumerable<DbColumn> FilterColumns {
111      get { return this.columns.Where(col => col.FilterColumn); }
112    }
113
114    public void UpdateInformationLoaded() {
115      this.informationLoaded = DateTime.Now;
116    }
117
118    public bool ReloadOfInformationNeeded {
119      get { return DateTime.Now.Subtract(this.InformationLoaded).Minutes > 5; }
120    }
121
122    public override string ToString() {
123      string s = this.tableName + "   " + SelectedColumnsCount + "/" + this.columns.Count;
124      return s;
125    }
126  }
127}
Note: See TracBrowser for help on using the repository browser.