Update: Update Job Identifiers
This commit is contained in:
@@ -34,6 +34,9 @@
|
|||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@@ -176,12 +179,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
<UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_StartDate="2014/6/1" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" />
|
<UserProperties BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_StartDate="2014/6/1" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" />
|
||||||
</VisualStudio>
|
</VisualStudio>
|
||||||
</ProjectExtensions>
|
</ProjectExtensions>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Disco.Models.Services.Interop.DiscoServices
|
namespace Disco.Models.Services.Interop.DiscoServices
|
||||||
@@ -21,18 +22,31 @@ namespace Disco.Models.Services.Interop.DiscoServices
|
|||||||
|
|
||||||
public List<StatisticString> InstalledPlugins { get; set; }
|
public List<StatisticString> InstalledPlugins { get; set; }
|
||||||
|
|
||||||
|
public List<StatisticIntPair> Stat_JobIdentifiers { get; set; }
|
||||||
public List<StatisticJob> Stat_Jobs { get; set; }
|
public List<StatisticJob> Stat_Jobs { get; set; }
|
||||||
|
|
||||||
|
public class StatisticIntPair
|
||||||
|
{
|
||||||
|
[JsonProperty("B")]
|
||||||
|
public int Begin;
|
||||||
|
[JsonProperty("E")]
|
||||||
|
public int End;
|
||||||
|
}
|
||||||
|
|
||||||
public class StatisticInt
|
public class StatisticInt
|
||||||
{
|
{
|
||||||
public string K;
|
[JsonProperty("K")]
|
||||||
public int V;
|
public string Key;
|
||||||
|
[JsonProperty("V")]
|
||||||
|
public int Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StatisticString
|
public class StatisticString
|
||||||
{
|
{
|
||||||
public string K;
|
[JsonProperty("K")]
|
||||||
public string V;
|
public string Key;
|
||||||
|
[JsonProperty("V")]
|
||||||
|
public string Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StatisticJob
|
public class StatisticJob
|
||||||
@@ -40,62 +54,74 @@ namespace Disco.Models.Services.Interop.DiscoServices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Job Identifier
|
/// Job Identifier
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int I { get; set; }
|
[JsonProperty("I")]
|
||||||
|
public int Identifier { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opened Date
|
/// Opened Date
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime OD { get; set; }
|
[JsonProperty("OD")]
|
||||||
|
public DateTime OpenedDate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Closed Date
|
/// Closed Date
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? CD { get; set; }
|
[JsonProperty("CD", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public DateTime? ClosedDate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Job Type
|
/// Job Type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string T { get; set; }
|
[JsonProperty("T")]
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Job Sub Types (Semicolon Separated)
|
/// Job Sub Types (Semicolon Separated)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ST { get; set; }
|
[JsonProperty("ST")]
|
||||||
|
public string SubTypes { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deployment-Unique Device Serial Identifier (Device Serial Number anonymized via hashing salted with Deployment Secret)
|
/// Deployment-Unique Device Serial Identifier (Device Serial Number anonymized via hashing salted with Deployment Secret)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string D { get; set; }
|
[JsonProperty("D", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string DeviceIdentifier { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deployment-Unique Job User Identifier (Job User Id anonymized via hashing salted with Deployment Secret)
|
/// Deployment-Unique Job User Identifier (Job User Id anonymized via hashing salted with Deployment Secret)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string U { get; set; }
|
[JsonProperty("U", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string UserIdentifier { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deployment-Unique Job Technician Identifier (Job Technician Id anonymized via hashing salted with Deployment Secret)
|
/// Deployment-Unique Job Technician Identifier (Job Technician Id anonymized via hashing salted with Deployment Secret)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TI { get; set; }
|
[JsonProperty("TI")]
|
||||||
|
public string TechnicianIdentifier { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Device Model
|
/// Device Model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DM { get; set; }
|
[JsonProperty("DM", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string DeviceModel { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// External Repairer
|
/// External Repairer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string R { get; set; }
|
[JsonProperty("R", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public string Repairer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// External Repairer Logged
|
/// External Repairer Logged
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? RL { get; set; }
|
[JsonProperty("RL", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public DateTime? RepairerLogged { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// External Repairer Completed
|
/// External Repairer Completed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? RC { get; set; }
|
[JsonProperty("RC", NullValueHandling = NullValueHandling.Ignore)]
|
||||||
|
public DateTime? RepairerCompleted { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
@@ -17,6 +17,7 @@ namespace Disco.Services.Interop.DiscoServices
|
|||||||
using StatisticInt = UpdateRequestV2.StatisticInt;
|
using StatisticInt = UpdateRequestV2.StatisticInt;
|
||||||
using StatisticJob = UpdateRequestV2.StatisticJob;
|
using StatisticJob = UpdateRequestV2.StatisticJob;
|
||||||
using StatisticString = UpdateRequestV2.StatisticString;
|
using StatisticString = UpdateRequestV2.StatisticString;
|
||||||
|
using StatisticIntPair = UpdateRequestV2.StatisticIntPair;
|
||||||
|
|
||||||
public static class UpdateQuery
|
public static class UpdateQuery
|
||||||
{
|
{
|
||||||
@@ -63,7 +64,6 @@ namespace Disco.Services.Interop.DiscoServices
|
|||||||
Status.UpdateStatus(10, "Gathering statistics and building update request");
|
Status.UpdateStatus(10, "Gathering statistics and building update request");
|
||||||
|
|
||||||
var updateRequest = BuildRequest(Database);
|
var updateRequest = BuildRequest(Database);
|
||||||
var updateRequestJson = JsonConvert.SerializeObject(updateRequest);
|
|
||||||
|
|
||||||
Status.UpdateStatus(40, "Sending statistics and update request");
|
Status.UpdateStatus(40, "Sending statistics and update request");
|
||||||
|
|
||||||
@@ -87,7 +87,9 @@ namespace Disco.Services.Interop.DiscoServices
|
|||||||
{
|
{
|
||||||
using (var requestStreamWriter = new StreamWriter(compressedStream, Encoding.UTF8))
|
using (var requestStreamWriter = new StreamWriter(compressedStream, Encoding.UTF8))
|
||||||
{
|
{
|
||||||
requestStreamWriter.Write(updateRequestJson);
|
JsonSerializer serializer = new JsonSerializer();
|
||||||
|
serializer.Serialize(requestStreamWriter, updateRequest);
|
||||||
|
|
||||||
requestStreamWriter.Flush();
|
requestStreamWriter.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,19 +145,38 @@ namespace Disco.Services.Interop.DiscoServices
|
|||||||
if (whoAmIResponse != null && !string.IsNullOrWhiteSpace(whoAmIResponse.Item1))
|
if (whoAmIResponse != null && !string.IsNullOrWhiteSpace(whoAmIResponse.Item1))
|
||||||
m.VicEduDeptWanId = whoAmIResponse.Item1;
|
m.VicEduDeptWanId = whoAmIResponse.Item1;
|
||||||
|
|
||||||
m.Stat_JobCounts = Database.Jobs.GroupBy(j => j.JobTypeId).Select(g => new StatisticInt() { K = g.Key, V = g.Count() }).ToList();
|
m.Stat_JobCounts = Database.Jobs.GroupBy(j => j.JobTypeId).Select(g => new StatisticInt() { Key = g.Key, Value = g.Count() }).ToList();
|
||||||
m.Stat_OpenJobCounts = Database.Jobs.Where(j => j.ClosedDate == null).GroupBy(j => j.JobTypeId).Select(g => new StatisticInt() { K = g.Key, V = g.Count() }).ToList();
|
m.Stat_OpenJobCounts = Database.Jobs.Where(j => j.ClosedDate == null).GroupBy(j => j.JobTypeId).Select(g => new StatisticInt() { Key = g.Key, Value = g.Count() }).ToList();
|
||||||
m.Stat_DeviceModelCounts = Database.DeviceModels.Select(dm => new StatisticInt() { K = dm.Manufacturer + ";" + dm.Model, V = dm.Devices.Count(d => d.DecommissionedDate == null) }).ToList();
|
m.Stat_DeviceModelCounts = Database.DeviceModels.Select(dm => new StatisticInt() { Key = dm.Manufacturer + ";" + dm.Model, Value = dm.Devices.Count(d => d.DecommissionedDate == null) }).ToList();
|
||||||
var activeThreshold = DateTime.Now.AddDays(-60);
|
var activeThreshold = DateTime.Now.AddDays(-60);
|
||||||
m.Stat_ActiveDeviceModelCounts = Database.DeviceModels.Select(dm => new StatisticInt() { K = dm.Manufacturer + ";" + dm.Model, V = dm.Devices.Count(d => d.DecommissionedDate == null && (d.LastNetworkLogonDate == null || d.LastNetworkLogonDate > activeThreshold)) }).ToList();
|
m.Stat_ActiveDeviceModelCounts = Database.DeviceModels.Select(dm => new StatisticInt() { Key = dm.Manufacturer + ";" + dm.Model, Value = dm.Devices.Count(d => d.DecommissionedDate == null && (d.LastNetworkLogonDate == null || d.LastNetworkLogonDate > activeThreshold)) }).ToList();
|
||||||
m.Stat_UserCounts = new List<StatisticInt>() {
|
m.Stat_UserCounts = new List<StatisticInt>() {
|
||||||
new StatisticInt() { K = "All", V = Database.Users.Count() },
|
new StatisticInt() { Key = "All", Value = Database.Users.Count() },
|
||||||
new StatisticInt() { K = "Assigned Current", V = Database.Users.Where(u => u.DeviceUserAssignments.Any(dua => !dua.UnassignedDate.HasValue)).Count() },
|
new StatisticInt() { Key = "Assigned Current", Value = Database.Users.Where(u => u.DeviceUserAssignments.Any(dua => !dua.UnassignedDate.HasValue)).Count() },
|
||||||
new StatisticInt() { K = "Assigned Ever", V = Database.Users.Where(u => u.DeviceUserAssignments.Any()).Count() },
|
new StatisticInt() { Key = "Assigned Ever", Value = Database.Users.Where(u => u.DeviceUserAssignments.Any()).Count() },
|
||||||
new StatisticInt() { K = "Job Technicians", V = Database.Jobs.Select(j => j.OpenedTechUserId).Distinct().ToList().Concat(Database.Jobs.Select(j => j.ClosedTechUserId).Distinct().ToList()).Distinct().Count() },
|
new StatisticInt() { Key = "Job Technicians", Value = Database.Jobs.Select(j => j.OpenedTechUserId).Distinct().ToList().Concat(Database.Jobs.Select(j => j.ClosedTechUserId).Distinct().ToList()).Distinct().Count() },
|
||||||
new StatisticInt() { K = "Job Users", V = Database.Jobs.Where(j => j.UserId != null).Select(j => j.UserId).Distinct().Count() }
|
new StatisticInt() { Key = "Job Users", Value = Database.Jobs.Where(j => j.UserId != null).Select(j => j.UserId).Distinct().Count() }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var jobIds = Database.Jobs.OrderBy(j => j.Id).Select(j => j.Id).ToList();
|
||||||
|
if (jobIds.Count > 0)
|
||||||
|
{
|
||||||
|
m.Stat_JobIdentifiers = new List<StatisticIntPair>();
|
||||||
|
var jobIdSequenceBegin = jobIds.First();
|
||||||
|
jobIds.Skip(1).Aggregate(jobIdSequenceBegin, (last, current) =>
|
||||||
|
{
|
||||||
|
if (current == last + 1)
|
||||||
|
return current;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m.Stat_JobIdentifiers.Add(new StatisticIntPair() { Begin = jobIdSequenceBegin, End = last });
|
||||||
|
jobIdSequenceBegin = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
return current;
|
||||||
|
});
|
||||||
|
m.Stat_JobIdentifiers.Add(new StatisticIntPair() { Begin = jobIdSequenceBegin, End = jobIds.Last() });
|
||||||
|
|
||||||
IQueryable<Job> jobs;
|
IQueryable<Job> jobs;
|
||||||
if (lastUpdate == null)
|
if (lastUpdate == null)
|
||||||
jobs = Database.Jobs;
|
jobs = Database.Jobs;
|
||||||
@@ -187,21 +208,22 @@ namespace Disco.Services.Interop.DiscoServices
|
|||||||
|
|
||||||
m.Stat_Jobs = reportedJobs.Select(j => new StatisticJob()
|
m.Stat_Jobs = reportedJobs.Select(j => new StatisticJob()
|
||||||
{
|
{
|
||||||
I = j.Id,
|
Identifier = j.Id,
|
||||||
OD = j.OpenedDate,
|
OpenedDate = j.OpenedDate,
|
||||||
CD = j.ClosedDate,
|
ClosedDate = j.ClosedDate,
|
||||||
T = j.JobType,
|
Type = j.JobType,
|
||||||
ST = j.JobSubTypes == null ? null : string.Join(";", j.JobSubTypes),
|
SubTypes = j.JobSubTypes == null ? null : string.Join(";", j.JobSubTypes),
|
||||||
D = HashDeploymentData(Database, j.DeviceSerialNumber),
|
DeviceIdentifier = HashDeploymentData(Database, j.DeviceSerialNumber),
|
||||||
U = HashDeploymentData(Database, j.UserId),
|
UserIdentifier = HashDeploymentData(Database, j.UserId),
|
||||||
TI = HashDeploymentData(Database, j.JobTechnicianId),
|
TechnicianIdentifier = HashDeploymentData(Database, j.JobTechnicianId),
|
||||||
DM = string.Format("{0};{1}", j.DeviceModelManufacturer, j.DeviceModelModel),
|
DeviceModel = string.Format("{0};{1}", j.DeviceModelManufacturer, j.DeviceModelModel),
|
||||||
R = j.JobType == JobType.JobTypeIds.HWar ? j.WarrantyRepairer : j.Repairer,
|
Repairer = j.JobType == JobType.JobTypeIds.HWar ? j.WarrantyRepairer : j.Repairer,
|
||||||
RL = j.JobType == JobType.JobTypeIds.HWar ? j.WarrantyRepairerLoggedDate : j.RepairerLoggedDate,
|
RepairerLogged = j.JobType == JobType.JobTypeIds.HWar ? j.WarrantyRepairerLoggedDate : j.RepairerLoggedDate,
|
||||||
RC = j.JobType == JobType.JobTypeIds.HWar ? j.WarrantyRepairerCompletedDate : j.RepairerCompletedDate
|
RepairerCompleted = j.JobType == JobType.JobTypeIds.HWar ? j.WarrantyRepairerCompletedDate : j.RepairerCompletedDate
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
m.InstalledPlugins = Disco.Services.Plugins.Plugins.GetPlugins().Select(manifest => new StatisticString() { K = manifest.Id, V = manifest.VersionFormatted }).ToList();
|
m.InstalledPlugins = Disco.Services.Plugins.Plugins.GetPlugins().Select(manifest => new StatisticString() { Key = manifest.Id, Value = manifest.VersionFormatted }).ToList();
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user