Update #15: Community Reporting

Active Devices are more correctly reported, and metrics on warranty job
vendor logging.
This commit is contained in:
Gary Sharp
2013-10-29 14:36:29 +11:00
parent df633b3591
commit 76aead2011
3 changed files with 14 additions and 14 deletions
+8 -7
View File
@@ -1,16 +1,14 @@
using System;
using Disco.Data.Repository;
using Disco.Models.BI.Interop.Community;
using Disco.Models.Repository;
using Disco.Services.Tasks;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Serialization;
using Disco.Data.Repository;
using Disco.Models.BI.Interop.Community;
using Disco.Services.Tasks;
using Newtonsoft.Json;
namespace Disco.BI.Interop.Community
{
@@ -108,6 +106,7 @@ namespace Disco.BI.Interop.Community
m.Stat_JobCounts = Database.Jobs.GroupBy(j => j.JobTypeId).Select(g => new Disco.Models.BI.Interop.Community.UpdateRequestV1.Stat { Key = g.Key, Count = g.Count() }).ToList();
m.Stat_OpenJobCounts = Database.Jobs.Where(j => j.ClosedDate == null).GroupBy(j => j.JobTypeId).Select(g => new Disco.Models.BI.Interop.Community.UpdateRequestV1.Stat { Key = g.Key, Count = g.Count() }).ToList();
m.Stat_DeviceModelCounts = Database.DeviceModels.Select(dm => new Disco.Models.BI.Interop.Community.UpdateRequestV1.Stat { Key = dm.Manufacturer + ";" + dm.Model, Count = dm.Devices.Count(d => d.DecommissionedDate == null) }).ToList();
var activeThreshold = DateTime.Now.AddDays(-60);
m.Stat_ActiveDeviceModelCounts = Database.DeviceModels.Select(dm => new Disco.Models.BI.Interop.Community.UpdateRequestV1.Stat { Key = dm.Manufacturer + ";" + dm.Model, Count = dm.Devices.Count(d => d.DecommissionedDate == null && (d.LastNetworkLogonDate == null || d.LastNetworkLogonDate > activeThreshold)) }).ToList();
m.Stat_UserCounts = new List<UpdateRequestV1.Stat>() {
@@ -117,6 +116,8 @@ namespace Disco.BI.Interop.Community
}
};
m.Stat_JobWarrantyVendorCounts = Database.Jobs.Where(j => j.JobTypeId == JobType.JobTypeIds.HWar && j.JobMetaWarranty.ExternalLoggedDate.HasValue && j.JobMetaWarranty.ExternalName != null).GroupBy(j => j.JobMetaWarranty.ExternalName).Select(g => new Disco.Models.BI.Interop.Community.UpdateRequestV1.Stat { Key = g.Key ?? "<Unknown>", Count = g.Count() }).ToList();
m.InstalledPlugins = Disco.Services.Plugins.Plugins.GetPlugins().Select(manifest => new Disco.Models.BI.Interop.Community.UpdateRequestV1.PluginRef { Id = manifest.Id, Version = manifest.VersionFormatted }).ToList();
return m;
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.Data.Repository;
using Disco.Services.Logging;
using Disco.Data.Repository;
using Disco.Services.Tasks;
using Quartz;
using System;
using System.Linq;
namespace Disco.BI.Interop.Community
{
@@ -20,10 +20,13 @@ namespace Disco.Models.BI.Interop.Community
public List<Stat> Stat_JobCounts { get; set; }
public List<Stat> Stat_OpenJobCounts { get; set; }
public List<Stat> Stat_ActiveDeviceModelCounts { get; set; }
public List<Stat> Stat_DeviceModelCounts { get; set; }
public List<Stat> Stat_UserCounts { get; set; }
public List<PluginRef> InstalledPlugins { get; set; }
public List<Stat> Stat_JobWarrantyVendorCounts { get; set; }
public class Stat
{
public string Key { get; set; }