Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.DataImporter/HeuristicLab.DataImporter.DbExplorer.Interfaces/DbTable.cs @ 17507

Last change on this file since 17507 was 16567, checked in by gkronber, 6 years ago

#2520: changed StorableConstructors and added StorableType attributes in HeuristicLab.DataImporter addon

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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 HEAL.Attic;
26
27namespace HeuristicLab.DataImporter.DbExplorer.Interfaces {
28  [StorableType("A0613D0D-C6C6-4958-9F26-8810E84EAD27")]
29  public class DbTable {
30    [StorableConstructor]
31    protected DbTable(StorableConstructorFlag _) {
32      this.informationLoaded = new DateTime(1990, 1, 1);
33    }
34
35    public DbTable(string ownerName, string tableName)
36      : base() {
37      this.informationLoaded = new DateTime(1990, 1, 1);
38      this.columns = new List<DbColumn>();
39      this.ownerName = ownerName;
40      this.tableName = tableName;
41    }
42
43    [Storable]
44    private string ownerName;
45    public string OwnerName {
46      get { return this.ownerName; }
47      set { this.ownerName = value; }
48    }
49
50    [Storable]
51    private string tableName;
52    public string TableName {
53      get { return this.tableName; }
54      set { this.tableName = value; }
55    }
56
57    [Storable]
58    private List<DbColumn> columns;
59    public IEnumerable<DbColumn> Columns {
60      get { return this.columns; }
61    }
62
63    public bool IsSelected {
64      get { return columns.Any(col => col.Selected); }
65    }
66
67    private int affectedRows;
68    public int AffectedRows {
69      get { return this.affectedRows; }
70      set { this.affectedRows = value; }
71    }
72
73    private int totalRows;
74    public int TotalRows {
75      get { return this.totalRows; }
76      set { this.totalRows = value; }
77    }
78
79    private DateTime informationLoaded;
80    public DateTime InformationLoaded {
81      get { return this.informationLoaded; }
82    }
83
84    public void AddColumn(DbColumn column) {
85      this.columns.Add(column);
86    }
87
88    public void ClearSelection() {
89      foreach (DbColumn col in columns) {
90        col.Selected = false;
91        col.FilterColumn = false;
92        col.LikeValue = "";
93      }
94    }
95
96    public void SelectAllColumns() {
97      foreach (DbColumn col in this.columns)
98        col.Selected = true;
99    }
100
101    public int SelectedColumnsCount {
102      get { return this.columns.Count(col => col.Selected); }
103    }
104
105    public IEnumerable<DbColumn> SelectedColumns {
106      get { return this.columns.Where(col => col.Selected); }
107    }
108
109    public IEnumerable<DbColumn> FilterColumns {
110      get { return this.columns.Where(col => col.FilterColumn); }
111    }
112
113    public void UpdateInformationLoaded() {
114      this.informationLoaded = DateTime.Now;
115    }
116
117    public bool ReloadOfInformationNeeded {
118      get { return DateTime.Now.Subtract(this.InformationLoaded).Minutes > 5; }
119    }
120
121    public override string ToString() {
122      string s = this.tableName + "   " + SelectedColumnsCount + "/" + this.columns.Count;
123      return s;
124    }
125  }
126}
Note: See TracBrowser for help on using the repository browser.