[12761] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16565] | 3 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[12761] | 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 |
|
---|
| 22 | using System.Collections.Generic;
|
---|
| 23 | using System.Linq;
|
---|
| 24 | using System.Web.Http;
|
---|
| 25 | using HeuristicLab.Services.Hive;
|
---|
| 26 | using HeuristicLab.Services.Hive.DataAccess.Interfaces;
|
---|
| 27 | using HeuristicLab.Services.WebApp.Maintenance.WebApi.DataTransfer;
|
---|
| 28 | using DA = HeuristicLab.Services.Hive.DataAccess.Data;
|
---|
| 29 |
|
---|
| 30 | namespace HeuristicLab.Services.WebApp.Maintenance.WebApi {
|
---|
| 31 | public class SpaceUsageController : ApiController {
|
---|
| 32 | private IPersistenceManager PersistenceManager {
|
---|
| 33 | get { return ServiceLocator.Instance.PersistenceManager; }
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | public IEnumerable<TableInformation> GetHiveTableInformation() {
|
---|
| 37 | var tables = new List<string> {
|
---|
[16117] | 38 | "AssignedJobResource",
|
---|
| 39 | "AssignedProjectResource",
|
---|
[12761] | 40 | "Downtime",
|
---|
| 41 | "Job",
|
---|
| 42 | "JobPermission",
|
---|
| 43 | "Lifecycle",
|
---|
| 44 | "Plugin",
|
---|
| 45 | "PluginData",
|
---|
[16117] | 46 | "Project",
|
---|
| 47 | "ProjectPermission",
|
---|
[12761] | 48 | "RequiredPlugins",
|
---|
| 49 | "Resource",
|
---|
| 50 | "StateLog",
|
---|
| 51 | "Task",
|
---|
| 52 | "TaskData",
|
---|
| 53 | "UserPriority"
|
---|
| 54 | };
|
---|
[12858] | 55 | var pm = PersistenceManager;
|
---|
| 56 | return pm.UseTransaction(() => (
|
---|
[12761] | 57 | from table in tables
|
---|
| 58 | select pm.GetTableInformation(table) into tableInformation
|
---|
| 59 | where tableInformation != null
|
---|
| 60 | select Convert(tableInformation)
|
---|
| 61 | ).ToList()
|
---|
| 62 | );
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | public IEnumerable<TableInformation> GetStatisticsTableInformation() {
|
---|
| 66 | var tables = new List<string> {
|
---|
| 67 | "statistics.DimClient",
|
---|
| 68 | "statistics.DimJob",
|
---|
[16117] | 69 | "statistics.DimProject",
|
---|
[12761] | 70 | "statistics.DimTime",
|
---|
| 71 | "statistics.DimUser",
|
---|
| 72 | "statistics.FactClientInfo",
|
---|
[16117] | 73 | "statistics.FactProjectInfo",
|
---|
[12761] | 74 | "statistics.FactTask"
|
---|
| 75 | };
|
---|
[12858] | 76 | var pm = PersistenceManager;
|
---|
| 77 | return pm.UseTransaction(() => (
|
---|
[12761] | 78 | from table in tables
|
---|
| 79 | select pm.GetTableInformation(table) into tableInformation
|
---|
| 80 | where tableInformation != null
|
---|
| 81 | select Convert(tableInformation)
|
---|
| 82 | ).ToList()
|
---|
| 83 | );
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | private TableInformation Convert(DA.TableInformation tableInformation) {
|
---|
| 87 | return new TableInformation {
|
---|
| 88 | Name = tableInformation.Name,
|
---|
| 89 | Rows = tableInformation.Rows,
|
---|
| 90 | Reserved = tableInformation.Reserved,
|
---|
| 91 | Data = tableInformation.Data,
|
---|
| 92 | IndexSize = tableInformation.IndexSize,
|
---|
| 93 | Unused = tableInformation.Unused
|
---|
| 94 | };
|
---|
| 95 | }
|
---|
| 96 | }
|
---|
| 97 | }
|
---|