Changeset 12858 for branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi
- Timestamp:
- 08/13/15 15:22:51 (9 years ago)
- Location:
- branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactClientInfoController.cs
r12777 r12858 36 36 37 37 public DT.FactClientInfo GetFactClientInfo(DateTime start, DateTime end) { 38 using (var pm = PersistenceManager) { 39 var factClientInfo = pm.FactClientInfoDao; 40 var query = factClientInfo.GetAll().Where(x => x.Time >= start && x.Time <= end); 41 return new DT.FactClientInfo { 42 Rows = query.Count(), 43 Clients = query.Select(x => x.ClientId).Distinct().Count() 44 }; 45 } 38 var pm = PersistenceManager; 39 var factClientInfo = pm.FactClientInfoDao; 40 var query = factClientInfo.GetAll().Where(x => x.Time >= start && x.Time <= end); 41 return new DT.FactClientInfo { 42 Rows = query.Count(), 43 Clients = query.Select(x => x.ClientId).Distinct().Count() 44 }; 46 45 } 47 46 48 47 public void Aggregate(DateTime start, DateTime end, int entries) { 49 using (var pm = PersistenceManager) { 50 var factClientInfoDao = pm.FactClientInfoDao; 51 var dimTimeDao = pm.DimTimeDao; 52 var clientIds = pm.UseTransaction(() => factClientInfoDao.GetAll() 53 .Where(x => x.Time >= start && x.Time <= end) 54 .Select(x => x.ClientId) 55 .Distinct() 56 ); 57 foreach (var id in clientIds) { 58 AggregateClient(pm, id, start, end, entries); 59 } 60 dimTimeDao.DeleteUnusedTimes(); 48 var pm = PersistenceManager; 49 var factClientInfoDao = pm.FactClientInfoDao; 50 var dimTimeDao = pm.DimTimeDao; 51 var clientIds = pm.UseTransaction(() => factClientInfoDao.GetAll() 52 .Where(x => x.Time >= start && x.Time <= end) 53 .Select(x => x.ClientId) 54 .Distinct() 55 ); 56 foreach (var id in clientIds) { 57 AggregateClient(pm, id, start, end, entries); 61 58 } 59 dimTimeDao.DeleteUnusedTimes(); 62 60 } 63 61 -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/FactTaskController.cs
r12761 r12858 35 35 36 36 public DT.JobPage GetJobs(DateTime start, DateTime end, int page, int size) { 37 using (var pm = PersistenceManager) { 38 var dimJobDao = pm.DimJobDao; 39 var factTaskDao = pm.FactTaskDao; 40 return pm.UseTransaction(() => { 41 var query = dimJobDao.GetAll().Where(x => x.DateCreated >= start && x.DateCreated <= end); 42 return new DT.JobPage { 43 TotalJobs = query.Count(), 44 Jobs = query.OrderBy(x => x.DateCreated) 45 .Skip((page - 1) * size) 46 .Take(size) 47 .Select(x => new DT.Job { 48 Id = x.JobId, 49 Name = x.JobName, 50 Username = x.UserName, 51 DateCreated = x.DateCreated, 52 Tasks = x.TotalTasks, 53 Aggregated = !(factTaskDao.GetAll().Count(y => y.JobId == x.JobId) > 1) 54 }) 55 .ToList() 56 }; 57 }); 58 } 37 var pm = PersistenceManager; 38 var dimJobDao = pm.DimJobDao; 39 var factTaskDao = pm.FactTaskDao; 40 return pm.UseTransaction(() => { 41 var query = dimJobDao.GetAll().Where(x => x.DateCreated >= start && x.DateCreated <= end); 42 return new DT.JobPage { 43 TotalJobs = query.Count(), 44 Jobs = query.OrderBy(x => x.DateCreated) 45 .Skip((page - 1) * size) 46 .Take(size) 47 .Select(x => new DT.Job { 48 Id = x.JobId, 49 Name = x.JobName, 50 Username = x.UserName, 51 DateCreated = x.DateCreated, 52 Tasks = x.TotalTasks, 53 Aggregated = !(factTaskDao.GetAll().Count(y => y.JobId == x.JobId) > 1) 54 }) 55 .ToList() 56 }; 57 }); 59 58 } 60 59 61 60 [HttpPost] 62 61 public void AggregateJob(Guid id) { 63 using (var pm = PersistenceManager) { 64 AggregateJob(pm, id); 65 } 62 var pm = PersistenceManager; 63 AggregateJob(pm, id); 66 64 } 67 65 68 66 [HttpPost] 69 67 public void AggregateAllJobs(DateTime start, DateTime end) { 70 using (var pm = PersistenceManager) { 71 var dimJobDao = pm.DimJobDao; 72 var jobIds = pm.UseTransaction(() => dimJobDao.GetAll() 73 .Where(x => x.DateCreated >= start && x.DateCreated <= end) 74 .Select(x => x.JobId) 75 .ToList() 76 ); 77 foreach (var id in jobIds) { 78 AggregateJob(pm, id); 79 } 68 var pm = PersistenceManager; 69 var dimJobDao = pm.DimJobDao; 70 var jobIds = pm.UseTransaction(() => dimJobDao.GetAll() 71 .Where(x => x.DateCreated >= start && x.DateCreated <= end) 72 .Select(x => x.JobId) 73 .ToList() 74 ); 75 foreach (var id in jobIds) { 76 AggregateJob(pm, id); 80 77 } 81 78 } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/PluginController.cs
r12769 r12858 34 34 35 35 public DT.PluginPage GetUnusedPlugins(int page, int size) { 36 using (var pm = PersistenceManager) { 37 var pluginDao = pm.PluginDao; 38 var requiredPluginDao = pm.RequiredPluginDao; 39 var taskDao = pm.TaskDao; 40 return pm.UseTransaction(() => { 41 var taskIds = taskDao.GetAll().Select(x => x.TaskId); 42 var usedPluginIds = requiredPluginDao.GetAll() 43 .Where(x => taskIds.Contains(x.TaskId)) 44 .Select(x => x.PluginId) 45 .Distinct(); 46 var query = pluginDao.GetAll().Where(x => !usedPluginIds.Any(y => y == x.PluginId)); 47 return new DT.PluginPage { 48 TotalPlugins = query.Count(), 49 Plugins = query.OrderBy(x => x.DateCreated).ThenBy(x => x.Name) 50 .Skip((page - 1) * size) 51 .Take(size).Select(x => new DT.Plugin { 52 Id = x.PluginId, 53 Name = x.Name, 54 Version = x.Version, 55 DateCreated = x.DateCreated 56 }) 57 .ToList() 58 }; 59 }); 60 } 36 var pm = PersistenceManager; 37 var pluginDao = pm.PluginDao; 38 var requiredPluginDao = pm.RequiredPluginDao; 39 var taskDao = pm.TaskDao; 40 return pm.UseTransaction(() => { 41 var taskIds = taskDao.GetAll().Select(x => x.TaskId); 42 var usedPluginIds = requiredPluginDao.GetAll() 43 .Where(x => taskIds.Contains(x.TaskId)) 44 .Select(x => x.PluginId) 45 .Distinct(); 46 var query = pluginDao.GetAll().Where(x => !usedPluginIds.Any(y => y == x.PluginId)); 47 return new DT.PluginPage { 48 TotalPlugins = query.Count(), 49 Plugins = query.OrderBy(x => x.DateCreated).ThenBy(x => x.Name) 50 .Skip((page - 1) * size) 51 .Take(size).Select(x => new DT.Plugin { 52 Id = x.PluginId, 53 Name = x.Name, 54 Version = x.Version, 55 DateCreated = x.DateCreated 56 }) 57 .ToList() 58 }; 59 }); 61 60 } 62 61 63 62 [HttpPost] 64 63 public void DeletePlugin(Guid id) { 65 using (var pm = PersistenceManager) { 66 var pluginDao = pm.PluginDao; 67 pm.UseTransaction(() => { 68 pluginDao.Delete(id); 69 pm.SubmitChanges(); 70 }); 71 } 64 var pm = PersistenceManager; 65 var pluginDao = pm.PluginDao; 66 pm.UseTransaction(() => { 67 pluginDao.Delete(id); 68 pm.SubmitChanges(); 69 }); 72 70 } 73 71 74 72 [HttpPost] 75 73 public void DeleteUnusedPlugins() { 76 using (var pm = PersistenceManager) { 77 var pluginDao = pm.PluginDao; 78 pm.UseTransaction(() => { 79 pluginDao.DeleteUnusedPlugins(); 80 pm.SubmitChanges(); 81 }); 82 } 74 var pm = PersistenceManager; 75 var pluginDao = pm.PluginDao; 76 pm.UseTransaction(() => { 77 pluginDao.DeleteUnusedPlugins(); 78 pm.SubmitChanges(); 79 }); 83 80 } 84 81 } -
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Maintenance/3.3/WebApi/SpaceUsageController.cs
r12761 r12858 51 51 "UserPriority" 52 52 }; 53 using (var pm = PersistenceManager) {54 53 var pm = PersistenceManager; 54 return pm.UseTransaction(() => ( 55 55 from table in tables 56 56 select pm.GetTableInformation(table) into tableInformation … … 59 59 ).ToList() 60 60 ); 61 }62 61 } 63 62 … … 71 70 "statistics.FactTask" 72 71 }; 73 using (var pm = PersistenceManager) {74 72 var pm = PersistenceManager; 73 return pm.UseTransaction(() => ( 75 74 from table in tables 76 75 select pm.GetTableInformation(table) into tableInformation … … 79 78 ).ToList() 80 79 ); 81 }82 80 } 83 81
Note: See TracChangeset
for help on using the changeset viewer.