138 Commits

Author SHA1 Message Date
Gary Sharp 5f4cb20900 #138 display device flags where appropriate in the UI 2024-01-14 19:13:09 +11:00
Gary Sharp aee467cb53 #138 add/remove individual device flags UI 2024-01-14 18:29:58 +11:00
Gary Sharp 6ce6e2cccf #138 device flags configuration API and UI 2024-01-14 17:59:30 +11:00
Gary Sharp cd858c2215 #138 device flag searching 2024-01-14 17:56:20 +11:00
Gary Sharp 7e07c07171 #138 device flag export service 2024-01-14 17:55:20 +11:00
Gary Sharp 15e2806731 #138 device flag services 2024-01-14 17:54:06 +11:00
Gary Sharp 53baf4eb78 #138 device flag authorization claims 2024-01-13 16:56:23 +11:00
Gary Sharp 8c48ab6ecd #138 device flag models 2024-01-13 16:33:03 +11:00
Gary Sharp 8afe4195a9 #107 allow moving of device OU when changing profile 2024-01-12 12:53:50 +11:00
Gary Sharp dcc4fcb984 #107 support moving profiles devices when changing the organisational unit 2024-01-12 12:52:39 +11:00
Gary Sharp 4631903019 refactor: split windows/mac enrolment 2024-01-12 11:13:48 +11:00
Gary Sharp 85d51c0e45 Fix #141 preserve computer names for non-domain joined devices 2024-01-11 16:27:40 +11:00
Gary Sharp 974a07f3bb show a warning when a device profile OU couuld not be found 2023-11-24 12:58:12 +11:00
Gary Sharp b576aec641 feature: computer name template testing 2023-11-24 11:57:26 +11:00
Gary Sharp a2aaa4c913 #140 make additional fontawesome icons available for user flags 2023-11-12 21:25:16 +11:00
Gary Sharp 318a70d9a3 #140 upgrade fontawesome 2023-11-12 21:24:16 +11:00
Gary Sharp 53e57d4017 feature: user flag assignment exporting 2023-11-11 20:04:52 +11:00
Gary Sharp 143dc1b3e6 bug fix: when exporting devices refresh details before extracting records instead of after 2023-11-11 18:59:59 +11:00
Gary Sharp a4f18d1d49 initial refactor of device export so it can be reused for future exporting 2023-11-11 17:52:24 +11:00
Gary Sharp 46222f2a78 hide decommissioned device profiles and batches by default when updating a devices batch or profile 2023-11-09 20:48:16 +11:00
Gary Sharp 2e091383ec fixes #134 - hide decommissioned device profiles by default 2023-11-09 20:05:25 +11:00
Gary Sharp 7ace4d1c7e add padding row to device batch list to maintain alternating row styles 2023-11-09 19:55:22 +11:00
Gary Sharp f901d45d78 support Firefox checkbox inside anchor element when logging warranty 2023-11-09 14:05:48 +11:00
Gary Sharp 028d1ccc64 remove localhost-only requirement for post upgrade maintenance 2023-11-09 13:43:51 +11:00
Gary Sharp 7b6a44921d plugin library: link to configuration instead of disabled "installed" button 2023-11-09 13:43:09 +11:00
Gary Sharp 23406e5e39 include more inner exception data in system logging 2023-11-08 16:51:08 +11:00
Gary Sharp 83557e6f0c include external job references in detailed search 2023-11-08 16:49:19 +11:00
Gary Sharp 1c90c89158 upgrade ssh.net 2023-11-06 11:25:38 +11:00
Gary Sharp 9924153e82 upgrade dotnet framework 4.5 to 4.6 2023-11-06 11:24:58 +11:00
Gary Sharp 3ec2ea7d37 add job log when re-opening 2023-11-03 15:50:01 +11:00
Gary Sharp b6945d9bbd fix #135 avoid failing device import/enrol when unable to set AD description 2023-10-12 17:37:42 +11:00
Gary Sharp 6740a7479a bug: disable image (camera) attachment upload unless over HTTPS
Browser restriction: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#privacy_and_security
2023-10-12 16:34:35 +11:00
Gary Sharp a3fb09440d feature: document template QR Code image extensions 2023-10-12 16:07:14 +11:00
Gary Sharp 7353405b16 use native media devices to capture webcam images 2023-10-08 16:25:32 +11:00
Gary Sharp 6fcb1a1eae fixup Disco -> Disco ICT 2023-07-26 19:01:31 +10:00
Gary Sharp e204ea4d5f version bump for release candidate 2023-06-10 17:18:04 +10:00
Gary Sharp 0a4a2816a0 feature: bulk generate documents for device batches, models and profiles 2023-05-04 15:30:04 +10:00
Gary Sharp 473b02f718 bug fix: TryBinaryNumericEncode on small numbers 2023-05-04 15:27:46 +10:00
Gary Sharp 5a2c29ea0b bug: unable to bulk generate documents for devices/job; honor the id sort order 2023-05-04 13:06:04 +10:00
Gary Sharp 1a8ec32f0f view batch devices from index
requested by @RB
2023-04-28 15:39:44 +10:00
Gary Sharp 9e7daf2043 data tables remember pagination size preference 2023-04-28 14:36:01 +10:00
Gary Sharp 0c690cff5a bulk generation refactoring 2023-04-27 14:54:32 +10:00
Gary Sharp b55b77de9f initialize plugin scheduled tasks when installed 2023-04-26 18:16:46 +10:00
Gary Sharp 937508c440 document template user flag rules should use the creator user for flag assignment 2023-04-16 15:14:14 +10:00
Gary Sharp cfe4c4b912 refactor expression caching; add document fields 2023-04-16 14:02:35 +10:00
Gary Sharp d75663a219 document template on import user flag rules 2023-04-16 09:50:19 +10:00
Gary Sharp 1e24844e88 respect whitespace when rendering logs 2023-04-14 16:40:30 +10:00
Gary Sharp 273b67c422 support user details category in document bulk generation 2023-04-14 16:40:13 +10:00
Gary Sharp 13549e7ec4 bug fix: calculate task progress offsets and multiplier correctly 2023-04-14 16:39:14 +10:00
Gary Sharp bbb40bd5c4 register plugin references before initialization 2023-04-14 16:38:38 +10:00
Gary Sharp 22dad072b9 refactor user details plugin interface 2023-04-14 16:37:42 +10:00
Gary Sharp 215e9863a2 bug: client was unable to run djoin.exe
perhaps a behaviour change between dotnet 4.5 and 4.5.2. It was looking for djoin.exe in the SysWow directory.
2023-02-12 18:42:19 +11:00
Gary Sharp 190abc72dd bug: when adding computer offline, computer name should not be required 2023-02-09 20:03:20 +11:00
Gary Sharp af75a55d44 AddFlag helper method for expressions 2023-02-08 18:03:55 +11:00
Gary Sharp e05206d405 bug: correctly store email settings 2023-02-08 16:57:49 +11:00
Gary Sharp 53eed02a4f globally enable TLS1.2 2023-02-08 16:52:28 +11:00
Gary Sharp 57a7f67c3a remove device custom details
this plugin functionality has never been used
2023-02-08 16:24:21 +11:00
Gary Sharp 47e11c0fd6 bugs: minor 2023-01-29 10:10:37 +11:00
Gary Sharp 708ca16de8 minor framework updates 2023-01-29 10:07:19 +11:00
Gary Sharp 535a3f2967 bug: dont throw if unable to resolve online services 2023-01-28 13:37:27 +11:00
Gary Sharp ebd1c79f64 fix: increase pdf generated image resolution 2022-12-15 16:23:54 +11:00
Gary Sharp 7194dd612d bug: image montage layout 2022-12-15 16:08:24 +11:00
Gary Sharp 584bc07824 minor: when creating a job scoped document template default to all job types 2022-12-15 15:00:31 +11:00
Gary Sharp 2bd9238090 feature: support hiding user details with asterisk and ampersand suffixes 2022-12-09 12:23:41 +11:00
Gary Sharp b11fa5b1d6 Newtonsoft.Json 13.0.2 update 2022-12-08 11:15:34 +11:00
Gary Sharp 7667eaa49e maintenance: improved css minify 2022-12-04 15:21:04 +11:00
Gary Sharp 9f7c0f965e Microsoft.Owin update 2022-12-04 15:12:33 +11:00
Gary Sharp a274a33cf6 Newtonsoft.Json update 2022-12-04 15:05:51 +11:00
Gary Sharp 4acfd54319 Merge pull request #119 from garysharp/dependabot/nuget/Disco.Web.Extensions/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Web.Extensions
2022-12-04 14:20:40 +11:00
dependabot[bot] 941f1cf13e Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Web.Extensions
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 6.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/6.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-04 03:20:30 +00:00
Gary Sharp f225edd2d4 Merge pull request #118 from garysharp/dependabot/nuget/Disco.Data/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Data
2022-12-04 14:20:06 +11:00
Gary Sharp 5824680e2a Merge pull request #117 from garysharp/dependabot/nuget/Disco.Models/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Models
2022-12-04 14:19:55 +11:00
Gary Sharp ed4ec890da Merge pull request #120 from garysharp/dependabot/nuget/Disco.Client/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Client
2022-12-04 14:19:39 +11:00
Gary Sharp 56453fa081 Merge pull request #121 from garysharp/dependabot/nuget/Disco.Services/Newtonsoft.Json-13.0.1
Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Services
2022-12-04 14:19:25 +11:00
dependabot[bot] 11c824518f Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Client
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 6.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/6.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-04 03:18:33 +00:00
dependabot[bot] d720303a83 Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Data
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 6.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/6.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-04 03:18:32 +00:00
dependabot[bot] 02b29948ce Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Models
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 6.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/6.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-04 03:18:29 +00:00
dependabot[bot] a152365312 Bump Newtonsoft.Json from 6.0.3 to 13.0.1 in /Disco.Services
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 6.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/6.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-04 03:18:22 +00:00
Gary Sharp dba6c383f6 moment.js update 2022-12-04 14:17:31 +11:00
dependabot[bot] ba32b3b717 Bump Moment.js from 2.7.0 to 2.29.4 in /Disco.Web
Bumps [Moment.js](https://github.com/timrwood/moment) from 2.7.0 to 2.29.4.
- [Release notes](https://github.com/timrwood/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/timrwood/moment/compare/2.7.0...2.29.4)

---
updated-dependencies:
- dependency-name: Moment.js
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-04 14:00:00 +11:00
Gary Sharp 51cebd0706 maintenance: update T4MVC 2022-12-04 14:00:00 +11:00
Gary Sharp 983bdbefb9 maintenance: rebuild bundling/minify 2022-12-04 13:59:59 +11:00
Gary Sharp be99083d6a feature: bulk generating user documents 2022-12-04 13:47:24 +11:00
Gary Sharp 4c19a1ef63 minor: return correct content type for jpg 2022-12-04 13:47:24 +11:00
Gary Sharp 4f9f0fd0a8 maintenance: plugin refactoring 2022-12-04 13:47:24 +11:00
Gary Sharp 05593a1466 maintenance: document template refactoring 2022-12-04 13:47:23 +11:00
Gary Sharp 2873b4be8a bug: log detected thumbnail after collecting more information 2022-12-04 13:47:23 +11:00
Gary Sharp 7a1ff211a0 feature: user contact details 2022-12-04 13:47:23 +11:00
Gary Sharp fcf70f724e maintenance: dependency updates 2022-12-04 13:47:22 +11:00
Gary Sharp 99be87ed9c maintenance: AD integration refactoring 2022-12-04 13:47:22 +11:00
Gary Sharp 261baf669e fix: add accept attribute to file pickers 2022-12-04 13:47:22 +11:00
Gary Sharp b0fddd491b fix: simplify document template managed groups 2022-12-04 13:47:21 +11:00
Gary Sharp dff47c0e8b feature: export device custom details 2022-12-04 13:47:21 +11:00
Gary Sharp ed58619919 fix: configuration optimization 2022-12-04 13:47:20 +11:00
Gary Sharp 2a2731b9f3 feature: task-based document bulk generation 2022-12-04 13:47:20 +11:00
Gary Sharp 13e666d95a feature: document handlers 2022-12-04 13:47:19 +11:00
Gary Sharp 96cccab958 feature: pdf field locations cached 2022-12-04 13:47:18 +11:00
Gary Sharp e463a7361e feature: email address and phone numbers as links 2022-12-04 13:47:17 +11:00
Gary Sharp 58e467b6d6 feature: support importing device computer name 2022-12-04 13:47:17 +11:00
Gary Sharp 81bd6ccd83 bug: importing a PDF attachment fails if the template or target no longer exist 2022-09-07 18:08:28 +10:00
Gary Sharp 3e7db6b552 qol: remove exceptionless 2022-02-18 13:57:42 +11:00
Gary Sharp 09a6369693 qol: update javascript bundling 2022-02-18 13:52:31 +11:00
Gary Sharp 9bfeff8c42 feature: expose custom details to expressions
custom details can now be easily retrieved from any expression
2021-02-07 18:17:03 +11:00
Gary Sharp 3e57af394d feature: custom details first-class
custom details (such as those from the UserDetails plugin) can now be more deeply integrated throughtout the system
2021-02-07 18:15:52 +11:00
Gary Sharp e11d0871c4 feature: add reply-to address for email service 2021-02-05 15:24:20 +11:00
Gary Sharp f7fdfb0c8a maintenance unify document generation ui 2021-01-13 15:41:51 +11:00
Gary Sharp 806aadd161 feature: email service and configuration 2021-01-10 13:57:25 +11:00
Gary Sharp af4a94870e additional device details 2020-12-04 15:51:23 +11:00
Gary Sharp 486ce17857 Feature: Export device hardware audit information
Allows processor, memory, disk and network adapter information to be included in device exports
2020-11-29 16:46:20 +11:00
Gary Sharp f82b47dd46 Feature: Display detailed device hardware audit information
The device Details tab now displays processor, memory, disk and network adapter information collected at the previous enrolment
2020-11-29 16:45:10 +11:00
Gary Sharp f1d27732c7 Feature: Collect additional hardware audit information
When devices enrol the client collects processor, memory, disk and network information which is persisted in the database
2020-11-29 16:43:44 +11:00
Gary Sharp 28e5901929 Feature: Device Batch Attachments
allows for attachments to be uploaded and associated with Device Batches
2020-11-29 16:41:56 +11:00
Gary Sharp e531ffe2b7 support active directory trust relationships 2020-11-26 15:01:03 +11:00
Gary Sharp 4fca015afa bug fix: delete devices with assignment history 2020-11-13 20:15:31 +11:00
Gary Sharp a80ed14038 bug fix: csv device import first record was skipped 2020-09-10 12:43:03 +10:00
Gary Sharp f3e0939a06 Bug Fix: Ldap Query Escaping 2018-05-21 16:22:41 +10:00
Gary Sharp 2cd6ddfa24 Bug: EntityFramework does not understand Tuple.Create 2018-04-26 15:38:25 +10:00
Gary Sharp b4a30061e3 Bug fix #109 SQL Server 2016 Support 2018-04-23 18:21:44 +10:00
Gary Sharp cb033c0b70 Allow remote maintenance via web.config setting 2018-04-19 17:11:19 +10:00
Gary Sharp 3c197e7b2f Bug: Correctly write enrolment log device info 2018-04-19 17:09:34 +10:00
Gary Sharp 9f62da9ccd Bug: Stale cache when adding user flag in expression 2018-04-19 17:08:43 +10:00
Gary Sharp df721d7d6e Searching: Add detail to device search results 2018-04-19 17:06:58 +10:00
Gary Sharp 8278efb9a6 Bug: AD distinguishedName attribute name 2018-04-19 17:05:02 +10:00
Gary Sharp d477ad5d9c Client: Use UUID if no serial number is found 2018-04-19 17:04:25 +10:00
Gary Sharp 0755b6fc8a Workaround: Dont remove client certificates 2018-04-19 17:03:21 +10:00
Gary Sharp 78dd494304 Fix: Device import case-sensitive serial numbers 2018-04-19 17:02:38 +10:00
Gary Sharp 0497e145ea Bug fix: Allow for unexpected cert subject names 2017-05-25 13:47:17 +10:00
Gary Sharp 4d6aa18095 Perf: Save only when user updated 2017-03-29 13:00:15 +11:00
Gary Sharp fdf1bd4bc6 UI: Device models list, default hide decommissioned 2017-03-29 12:55:07 +11:00
Gary Sharp 82183f6508 UI: Device Table hide/show decommissioned devices 2017-03-29 12:18:37 +11:00
Gary Sharp d6ee70b860 Fix: NetBIOS computer name limit correction
16 character limit, not 24 as previously thought. Due to appended '$'
for machine accounts, a character limit of 15 is now enforced.
2017-03-29 12:17:01 +11:00
Gary Sharp 5ce9e51ae7 Feature: MS Excel (xlsx) Import/Export
Microsoft Excel files can be used to import/export devices. Several
import bugs were also fixed in the process.
2017-03-25 15:37:28 +11:00
Gary Sharp ed66f4f285 Tidy: Sort/remove usings, simplify names 2017-03-25 15:29:51 +11:00
Gary Sharp 526f8547f7 Client/Bootstrapper Fix: Try gathering model from BaseBoard 2017-03-24 15:50:18 +11:00
Gary Sharp d8e93cb31b Fix: Generate pdf for unimported users
If a user wasn't previously imported into the database generating of
PDFs failed. This change attempts to import the user if its not found.
2017-03-24 15:36:05 +11:00
Gary Sharp 5fa74a8cc0 Bug fix #106 - job queues: case-sensitive usernames 2016-12-08 17:01:13 +11:00
Gary Sharp a0d643eda1 Version bump for #103 2016-11-21 16:40:50 +11:00
Gary Sharp 0887eb447e Bug fix #103 Save User Flag assignment to DB 2016-11-21 16:02:45 +11:00
802 changed files with 86218 additions and 18822 deletions
+4
View File
@@ -0,0 +1,4 @@
[*.cs]
# VSSpell001: Spell Check
dotnet_diagnostic.VSSpell001.severity = suggestion
@@ -8,8 +8,8 @@ using Disco.Services.Expressions;
using Disco.Services.Interop.ActiveDirectory;
using iTextSharp.text.pdf;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -17,28 +17,58 @@ namespace Disco.BI.Extensions
{
public static class DocumentTemplateExtensions
{
internal const string CacheTemplate = "DocumentTemplate_{0}";
public static ConcurrentDictionary<string, Expression> PdfExpressionsFromCache(this DocumentTemplate dt, DiscoDataContext Database)
private static Tuple<Dictionary<string, Expression>, List<DocumentField>> CreateExpressions(DocumentTemplate dt, DiscoDataContext database)
{
string cacheModuleKey = string.Format(CacheTemplate, dt.Id);
var module = ExpressionCache.GetModule(cacheModuleKey);
if (module == null)
Dictionary<string, Expression> expressions = new Dictionary<string, Expression>();
List<DocumentField> fields = new List<DocumentField>();
string templateFilename = dt.RepositoryFilename(database);
PdfReader pdfReader = new PdfReader(templateFilename);
int pdfFieldOrdinal = 0;
foreach (string pdfFieldKey in pdfReader.AcroFields.Fields.Keys)
{
// Cache
string templateFilename = dt.RepositoryFilename(Database);
PdfReader pdfReader = new PdfReader(templateFilename);
int pdfFieldOrdinal = 0;
foreach (string pdfFieldKey in pdfReader.AcroFields.Fields.Keys)
var pdfField = pdfReader.AcroFields.Fields[pdfFieldKey];
var pdfFieldPositions = pdfReader.AcroFields.GetFieldPositions(pdfFieldKey);
var pdfFieldFlags = pdfField.GetMerged(0).GetAsNumber(PdfName.FF)?.IntValue ?? 0;
var isRequired = (pdfFieldFlags & 2) == 2;
var isReadOnly = (pdfFieldFlags & 1) == 1;
var pdfFieldValue = pdfReader.AcroFields.GetField(pdfFieldKey);
var pdfFieldPosition = default(RectangleF?);
if (pdfFieldPositions != null && pdfFieldPositions.Count > 0)
{
var pdfFieldValue = pdfReader.AcroFields.GetField(pdfFieldKey);
ExpressionCache.SetValue(cacheModuleKey, pdfFieldKey, Expression.Tokenize(pdfFieldKey, pdfFieldValue, pdfFieldOrdinal));
pdfFieldOrdinal++;
var position = pdfFieldPositions.First().position;
pdfFieldPosition = new RectangleF(position.Left, position.Top, position.Width, position.Height);
}
pdfReader.Close();
module = ExpressionCache.GetModule(cacheModuleKey, true);
var fieldTypeId = pdfReader.AcroFields.GetFieldType(pdfFieldKey);
var fieldType = DocumentFieldType.None;
if (fieldTypeId <= 8 && fieldTypeId > 0)
fieldType = (DocumentFieldType)fieldTypeId;
var fixedValues = default(List<string>);
if (fieldType == DocumentFieldType.RadioButton || fieldType == DocumentFieldType.Checkbox)
{
fixedValues = pdfReader.AcroFields.GetAppearanceStates(pdfFieldKey).ToList();
}
expressions[pdfFieldKey] = Expression.Tokenize(pdfFieldKey, pdfFieldValue, pdfFieldOrdinal, isRequired, isReadOnly, pdfFieldPosition);
fields.Add(new DocumentField(pdfFieldKey, pdfFieldValue, pdfFieldOrdinal, fieldType, isRequired, isReadOnly, fixedValues));
pdfFieldOrdinal++;
}
return module;
pdfReader.Close();
return Tuple.Create(expressions, fields);
}
public static Dictionary<string, Expression> PdfExpressionsFromCache(this DocumentTemplate dt, DiscoDataContext Database)
{
return ExpressionCache.GetOrCreateExpressions(dt, () => CreateExpressions(dt, Database));
}
public static List<DocumentField> PdfFieldsFromCache(this DocumentTemplate dt, DiscoDataContext Database)
{
return ExpressionCache.GetOrCreateFields(dt, () => CreateExpressions(dt, Database));
}
public static List<Expression> ExtractPdfExpressions(this DocumentTemplate dt, DiscoDataContext Database)
@@ -46,14 +76,6 @@ namespace Disco.BI.Extensions
return dt.PdfExpressionsFromCache(Database).Values.OrderBy(e => e.Ordinal).ToList();
}
public static Stream GeneratePdfBulk(this DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, params string[] DataObjectsIds)
{
return Interop.Pdf.PdfGenerator.GenerateBulkFromTemplate(dt, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjectsIds);
}
public static Stream GeneratePdfBulk(this DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, params IAttachmentTarget[] DataObjects)
{
return Interop.Pdf.PdfGenerator.GenerateBulkFromTemplate(dt, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjects);
}
public static Stream GeneratePdf(this DocumentTemplate dt, DiscoDataContext Database, IAttachmentTarget Target, User CreatorUser, DateTime TimeStamp, DocumentState State, bool FlattenFields = false)
{
bool generateExpression = !string.IsNullOrEmpty(dt.OnGenerateExpression);
+69 -27
View File
@@ -1,18 +1,18 @@
using Disco.BI.Extensions;
using Disco.Data.Repository;
using Disco.Models.BI.Expressions;
using Disco.Models.Repository;
using Disco.Models.Services.Documents;
using Disco.Models.Services.Expressions.Extensions;
using Disco.Services;
using Disco.Services.Documents;
using Disco.Services.Expressions;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Tasks;
using Disco.Services.Users;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.codec;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -120,15 +120,19 @@ namespace Disco.BI.Interop.Pdf
return bulkPdf;
}
}
public static Stream GenerateBulkFromTemplate(DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, params IAttachmentTarget[] DataObjects)
public static Stream GenerateBulkFromTemplate(DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, List<IAttachmentTarget> DataObjects, IScheduledTaskStatus taskStatus)
{
if (DataObjects.Length > 0)
if (DataObjects.Count > 0)
{
List<Stream> generatedPdfs = new List<Stream>(DataObjects.Length);
List<Stream> generatedPdfs = new List<Stream>(DataObjects.Count);
var progressPerDoc = 80d / DataObjects.Count;
var progressDoc = 10d;
using (var state = DocumentState.DefaultState())
{
taskStatus.UpdateStatus(10, "Rendering", "Starting");
foreach (var d in DataObjects)
{
taskStatus.UpdateStatus(progressDoc += progressPerDoc, $"Rendering {d.AttachmentReferenceId}");
generatedPdfs.Add(dt.GeneratePdf(Database, d, CreatorUser, Timestamp, state, true));
state.SequenceNumber++;
state.FlushScopeCache();
@@ -140,6 +144,7 @@ namespace Disco.BI.Interop.Pdf
}
else
{
taskStatus.UpdateStatus(90, "Merging", "Merging documents");
Stream bulkPdf = Utilities.JoinPdfs(InsertBlankPages, generatedPdfs);
foreach (Stream singlePdf in generatedPdfs)
singlePdf.Dispose();
@@ -149,35 +154,57 @@ namespace Disco.BI.Interop.Pdf
return null;
}
public static Stream GenerateBulkFromTemplate(DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, params string[] DataObjectsIds)
public static Stream GenerateBulkFromTemplate(DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, List<string> DataObjectsIds, IScheduledTaskStatus taskStatus)
{
IAttachmentTarget[] DataObjects;
Dictionary<string, IAttachmentTarget> dataObjectLookup;
List<string> dataObjectIds = DataObjectsIds;
taskStatus.UpdateStatus(0, "Resolving targets", "Resolving render targets");
switch (dt.Scope)
{
case DocumentTemplate.DocumentTemplateScopes.Device:
DataObjects = Database.Devices.Where(d => DataObjectsIds.Contains(d.SerialNumber)).ToArray();
dataObjectLookup = Database.Devices.Where(d => DataObjectsIds.Contains(d.SerialNumber)).AsEnumerable().Cast<IAttachmentTarget>().ToDictionary(i => i.AttachmentReferenceId, StringComparer.OrdinalIgnoreCase);
break;
case DocumentTemplate.DocumentTemplateScopes.Job:
int[] intDataObjectsIds = DataObjectsIds.Select(i => int.Parse(i)).ToArray();
DataObjects = Database.Jobs.Where(j => intDataObjectsIds.Contains(j.Id)).ToArray();
var intDataObjectsIds = DataObjectsIds.Select(i => int.Parse(i)).ToList();
dataObjectLookup = Database.Jobs.Where(j => intDataObjectsIds.Contains(j.Id)).AsEnumerable().Cast<IAttachmentTarget>().ToDictionary(i => i.AttachmentReferenceId, StringComparer.OrdinalIgnoreCase);
break;
case DocumentTemplate.DocumentTemplateScopes.User:
DataObjects = new IAttachmentTarget[DataObjectsIds.Length];
for (int idIndex = 0; idIndex < DataObjectsIds.Length; idIndex++)
dataObjectLookup = new Dictionary<string, IAttachmentTarget>(DataObjectsIds.Count, StringComparer.OrdinalIgnoreCase);
dataObjectIds = new List<string>(DataObjectsIds.Count);
foreach (var userId in DataObjectsIds)
{
string dataObjectId = DataObjectsIds[idIndex];
DataObjects[idIndex] = UserService.GetUser(ActiveDirectory.ParseDomainAccountId(dataObjectId), Database, true);
if (DataObjects[idIndex] == null)
throw new Exception($"Unknown Username specified: {dataObjectId}");
var user = UserService.GetUser(ActiveDirectory.ParseDomainAccountId(userId), Database, true);
if (user == null)
{
dataObjectIds.Add(userId);
continue;
}
dataObjectIds.Add(user.UserId);
dataObjectLookup.Add(user.UserId, user);
}
break;
default:
throw new InvalidOperationException("Invalid DocumentType Scope");
}
return GenerateBulkFromTemplate(dt, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjects);
// recreate list to honor the sort-order provided in DataObjectsIds
var dataObjects = new List<IAttachmentTarget>(DataObjectsIds.Count);
var missingIds = new List<string>();
foreach (var id in dataObjectIds)
{
if (dataObjectLookup.TryGetValue(id, out var dataObject))
dataObjects.Add(dataObject);
else
missingIds.Add(id);
}
if (missingIds.Any())
{
throw new Exception($"Unknown id specified: {string.Join("; ", missingIds)}");
}
return GenerateBulkFromTemplate(dt, Database, CreatorUser, Timestamp, InsertBlankPages, dataObjects, taskStatus);
}
public static Stream GenerateFromTemplate(DocumentTemplate dt, DiscoDataContext Database, IAttachmentTarget Data, User CreatorUser, DateTime TimeStamp, DocumentState State, bool FlattenFields = false)
@@ -207,7 +234,7 @@ namespace Disco.BI.Interop.Pdf
if (dt.FlattenForm)
FlattenFields = true;
ConcurrentDictionary<string, Expression> expressionCache = dt.PdfExpressionsFromCache(Database);
var expressionCache = dt.PdfExpressionsFromCache(Database);
string templateFilename = dt.RepositoryFilename(Database);
PdfReader pdfReader = new PdfReader(templateFilename);
@@ -218,7 +245,7 @@ namespace Disco.BI.Interop.Pdf
pdfStamper.FormFlattening = FlattenFields;
pdfStamper.Writer.CloseStream = false;
IDictionary expressionVariables = Expression.StandardVariables(dt, Database, CreatorUser, TimeStamp, State);
IDictionary expressionVariables = Expression.StandardVariables(dt, Database, CreatorUser, TimeStamp, State, Data);
foreach (string pdfFieldKey in pdfStamper.AcroFields.Fields.Keys)
{
@@ -227,7 +254,7 @@ namespace Disco.BI.Interop.Pdf
AcroFields.Item fields = pdfStamper.AcroFields.Fields[pdfFieldKey];
string fieldValue = dt.CreateUniqueIdentifier(Database, Data, CreatorUser, TimeStamp, 0).ToJson();
if (FlattenFields)
pdfStamper.AcroFields.SetField(pdfFieldKey, String.Empty);
pdfStamper.AcroFields.SetField(pdfFieldKey, string.Empty);
else
pdfStamper.AcroFields.SetField(pdfFieldKey, fieldValue);
@@ -241,16 +268,15 @@ namespace Disco.BI.Interop.Pdf
var pageUniqueIdBytes = pageUniqueId.ToQRCodeBytes();
// Encode to QRCode byte array
var pageUniqueIdWidth = (int)pdfFieldPosition.position.Width;
var pageUniqueIdHeight = (int)pdfFieldPosition.position.Height;
var pageUniqueIdEncoded = QRCodeBinaryEncoder.Encode(pageUniqueIdBytes, pageUniqueIdWidth, pageUniqueIdHeight);
var pageUniqueIdEncoded = QRCodeBinaryEncoder.Encode(pageUniqueIdBytes, out var qrWidth, out var qrHeight);
// Encode byte array to Image
var pageUniqueIdImageData = CCITTG4Encoder.Compress(pageUniqueIdEncoded, pageUniqueIdWidth, pageUniqueIdHeight);
var pageUniqueIdImage = iTextSharp.text.Image.GetInstance(pageUniqueIdWidth, pageUniqueIdHeight, false, 256, 1, pageUniqueIdImageData, null);
var pageUniqueIdImageData = CCITTG4Encoder.Compress(pageUniqueIdEncoded, qrWidth, qrHeight);
var pageUniqueIdImage = iTextSharp.text.Image.GetInstance(qrWidth, qrHeight, false, 256, 1, pageUniqueIdImageData, null);
// Add to the pdf page
pageUniqueIdImage.SetAbsolutePosition(pdfFieldPosition.position.Left, pdfFieldPosition.position.Bottom);
pageUniqueIdImage.ScaleToFit(pdfFieldPosition.position.Width, pdfFieldPosition.position.Height);
pdfStamper.GetOverContent(pdfFieldPosition.page).AddImage(pageUniqueIdImage);
}
// Hide Fields
@@ -288,8 +314,24 @@ namespace Disco.BI.Interop.Pdf
for (int pdfFieldOrdinal = 0; pdfFieldOrdinal < fields.Size; pdfFieldOrdinal++)
{
AcroFields.FieldPosition pdfFieldPosition = pdfFieldPositions[pdfFieldOrdinal];
iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(imageResult.GetImage((int)pdfFieldPosition.position.Width, (int)pdfFieldPosition.position.Height));
iTextSharp.text.Image pdfImage;
var imageWidth = (int)(pdfFieldPosition.position.Width * 1.6);
var imageHeight = (int)(pdfFieldPosition.position.Height * 1.6);
if (imageResult.Format == ImageExpressionFormat.Jpeg || imageResult.Format == ImageExpressionFormat.Png)
{
pdfImage = iTextSharp.text.Image.GetInstance(imageResult.GetImage(imageWidth, imageHeight));
}
else if (imageResult.Format == ImageExpressionFormat.CcittG4)
{
var imageData = imageResult.GetImage(out imageWidth, out imageHeight);
pdfImage = iTextSharp.text.Image.GetInstance(imageWidth, imageHeight, false, 256, 1, imageData.GetBuffer(), null);
}
else
throw new NotSupportedException($"Unexpected image format {imageResult.Format}");
pdfImage.SetAbsolutePosition(pdfFieldPosition.position.Left, pdfFieldPosition.position.Bottom);
pdfImage.ScaleToFit(pdfFieldPosition.position.Width, pdfFieldPosition.position.Height);
pdfStamper.GetOverContent(pdfFieldPosition.page).AddImage(pdfImage);
}
if (!fieldExpressionResult.Item2 && !imageResult.ShowField)
+7
View File
@@ -1,5 +1,7 @@
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.codec;
using System;
using System.Collections.Generic;
using System.IO;
@@ -7,6 +9,11 @@ namespace Disco.BI.Interop.Pdf
{
public static class Utilities
{
public static Func<byte[], int, int, byte[]> GetCCITTG4EncoderCompressDelegate()
{
return CCITTG4Encoder.Compress;
}
public static Stream JoinPdfs(bool InsertBlankPages, List<Stream> Pdfs)
{
if (Pdfs.Count == 0)
+1 -1
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco</RootNamespace>
<AssemblyName>Disco.BI</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+3 -3
View File
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.16320.1300")]
[assembly: AssemblyFileVersion("2.2.16320.1300")]
[assembly: AssemblyVersion("2.3.23161.0650")]
[assembly: AssemblyFileVersion("2.3.23161.0650")]
+1 -1
View File
@@ -19,7 +19,7 @@ namespace Disco.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
+23 -23
View File
@@ -1,57 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<system.serviceModel>
<bindings />
<client />
<bindings/>
<client/>
</system.serviceModel>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True" />
<parameter value="Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True"/>
</parameters>
</defaultConnectionFactory>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</configuration>
+23 -5
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -9,9 +9,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco.Client</RootNamespace>
<AssemblyName>Disco.Client</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
@@ -24,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Disco.Client.Program</StartupObject>
@@ -48,8 +49,8 @@
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -65,12 +66,24 @@
<Compile Include="..\Disco.Models\ClientServices\Enrol.cs">
<Link>Models\ClientServices\Enrol.cs</Link>
</Compile>
<Compile Include="..\Disco.Models\ClientServices\EnrolmentInformation\BaseBoard.cs">
<Link>Models\ClientServices\EnrolmentInformation\BaseBoard.cs</Link>
</Compile>
<Compile Include="..\Disco.Models\ClientServices\EnrolmentInformation\Battery.cs">
<Link>Models\ClientServices\EnrolmentInformation\Battery.cs</Link>
</Compile>
<Compile Include="..\Disco.Models\ClientServices\EnrolmentInformation\Bios.cs">
<Link>Models\ClientServices\EnrolmentInformation\Bios.cs</Link>
</Compile>
<Compile Include="..\Disco.Models\ClientServices\EnrolmentInformation\Certificate.cs">
<Link>Models\ClientServices\EnrolmentInformation\Certificate.cs</Link>
</Compile>
<Compile Include="..\Disco.Models\ClientServices\EnrolmentInformation\CertificateStore.cs">
<Link>Models\ClientServices\EnrolmentInformation\CertificateStore.cs</Link>
</Compile>
<Compile Include="..\Disco.Models\ClientServices\EnrolmentInformation\ComputerSystem.cs">
<Link>Models\ClientServices\EnrolmentInformation\ComputerSystem.cs</Link>
</Compile>
<Compile Include="..\Disco.Models\ClientServices\EnrolmentInformation\DeviceHardware.cs">
<Link>Models\ClientServices\EnrolmentInformation\DeviceHardware.cs</Link>
</Compile>
@@ -169,6 +182,11 @@
"$(ProjectDir)Package Creation\7z.exe" a -tzip "$(ProjectDir)Package Creation\PreparationClient.zip" "$(TargetDir)*.*" -x!*.tmp -x!*.vshost.* -x!Newtonsoft.Json.xml -x!*.pdb
COPY "$(ProjectDir)Package Creation\PreparationClient.zip" "$(ProjectDir)..\Disco.Web\ClientBin"</PostBuildEvent>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
@@ -8,13 +8,13 @@ namespace Disco.Client.Extensions
{
public static class ClientServicesExtensions
{
#if DEBUG
public const string ServicePathAuthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Authenticated/{0}";
public const string ServicePathUnauthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Unauthenticated/{0}";
#else
//#if DEBUG
// public const string ServicePathAuthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Authenticated/{0}";
// public const string ServicePathUnauthenticatedTemplate = "http://WS-GSHARP:57252/Services/Client/Unauthenticated/{0}";
//#else
public const string ServicePathAuthenticatedTemplate = "http://DISCO:9292/Services/Client/Authenticated/{0}";
public const string ServicePathUnauthenticatedTemplate = "http://DISCO:9292/Services/Client/Unauthenticated/{0}";
#endif
//#endif
public static ResponseType Post<ResponseType>(this ServiceBase<ResponseType> Service, bool Authenticated)
{
+467 -54
View File
@@ -1,6 +1,8 @@
using Disco.Models.ClientServices;
using Disco.Models.ClientServices.EnrolmentInformation;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Management;
@@ -40,18 +42,239 @@ namespace Disco.Client.Interop
throw new Exception($"The serial number reported by this device is over 60 characters long:\r\n{audit.SerialNumber}");
}
#warning TODO: Processors, PhysicalMemory, DiskDrives, etc
audit.ApplyProcessorInformation();
audit.ApplyPhysicalMemoryInformation();
audit.ApplyDiskDriveInformation();
audit.ApplyBatteryInformation();
audit.NetworkAdapters = Network.GetNetworkAdapters();
return audit;
}
private static void ApplyBIOSInformation(this DeviceHardware DeviceHardware)
private static void ApplyProcessorInformation(this DeviceHardware deviceHardware)
{
try
{
using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber, SMBIOSBIOSVersion FROM Win32_BIOS WHERE PrimaryBios=true"))
using (var mSearcher = new ManagementObjectSearcher("SELECT DeviceID, Manufacturer, Name, Description, Architecture, Family, MaxClockSpeed, NumberOfCores, NumberOfLogicalProcessors FROM Win32_Processor"))
{
using (var mResults = mSearcher.Get())
{
if (mResults.Count > 0)
{
var processors = new List<Processor>(mResults.Count);
foreach (var mItem in mResults.Cast<ManagementObject>())
{
if (mItem != null)
{
var processor = new Processor();
processor.DeviceID = (string)mItem.GetPropertyValue("DeviceID");
processor.Manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
processor.Name = (string)mItem.GetPropertyValue("Name");
processor.Description = (string)mItem.GetPropertyValue("Description");
processor.Family = (ushort?)mItem.GetPropertyValue("Family");
processor.MaxClockSpeed = (uint?)mItem.GetPropertyValue("MaxClockSpeed");
processor.NumberOfCores = (uint?)mItem.GetPropertyValue("NumberOfCores");
processor.NumberOfLogicalProcessors = (uint?)mItem.GetPropertyValue("NumberOfLogicalProcessors");
processor.Architecture = ((ProcessorArchitectures?)(ushort?)mItem.GetPropertyValue("Architecture"))?.ToString();
processors.Add(processor);
}
}
deviceHardware.Processors = processors;
}
}
}
}
catch (Exception)
{
// ignore errors to ensure backwards compatibility
}
}
private static void ApplyPhysicalMemoryInformation(this DeviceHardware deviceHardware)
{
try
{
using (var mSearcher = new ManagementObjectSearcher("SELECT Tag, SerialNumber, Manufacturer, PartNumber, Capacity, ConfiguredClockSpeed, Speed, DeviceLocator FROM Win32_PhysicalMemory"))
{
using (var mResults = mSearcher.Get())
{
if (mResults.Count > 0)
{
var physicalMemories = new List<PhysicalMemory>(mResults.Count);
foreach (var mItem in mResults.Cast<ManagementObject>())
{
if (mItem != null)
{
var physicalMemory = new PhysicalMemory();
physicalMemory.Tag = (string)mItem.GetPropertyValue("Tag");
physicalMemory.SerialNumber = (string)mItem.GetPropertyValue("SerialNumber");
physicalMemory.Manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
physicalMemory.PartNumber = (string)mItem.GetPropertyValue("PartNumber");
physicalMemory.Capacity = (ulong?)mItem.GetPropertyValue("Capacity");
physicalMemory.ConfiguredClockSpeed = (uint?)mItem.GetPropertyValue("ConfiguredClockSpeed");
physicalMemory.Speed = (uint?)mItem.GetPropertyValue("Speed");
physicalMemory.DeviceLocator = (string)mItem.GetPropertyValue("DeviceLocator");
physicalMemories.Add(physicalMemory);
}
}
deviceHardware.PhysicalMemory = physicalMemories;
}
}
}
}
catch (Exception)
{
// ignore errors to ensure backwards compatibility
}
}
private static void ApplyDiskDriveInformation(this DeviceHardware deviceHardware)
{
try
{
using (var diskSearcher = new ManagementObjectSearcher("SELECT DeviceID, Manufacturer, Model, MediaType, InterfaceType, SerialNumber, FirmwareRevision, Size FROM Win32_DiskDrive"))
{
using (var diskResults = diskSearcher.Get())
{
if (diskResults.Count > 0)
{
var diskDrives = new List<DiskDrive>(diskResults.Count);
foreach (var diskResult in diskResults.Cast<ManagementObject>())
{
if (diskResult != null)
{
var diskDrive = new DiskDrive();
diskDrive.DeviceID = (string)diskResult.GetPropertyValue("DeviceID");
diskDrive.Manufacturer = (string)diskResult.GetPropertyValue("Manufacturer");
diskDrive.Model = (string)diskResult.GetPropertyValue("Model");
diskDrive.MediaType = (string)diskResult.GetPropertyValue("MediaType");
diskDrive.InterfaceType = (string)diskResult.GetPropertyValue("InterfaceType");
diskDrive.SerialNumber = (string)diskResult.GetPropertyValue("SerialNumber");
diskDrive.FirmwareRevision = (string)diskResult.GetPropertyValue("FirmwareRevision");
diskDrive.Size = (ulong?)diskResult.GetPropertyValue("Size");
using (var partitionSearcher = new ManagementObjectSearcher($"ASSOCIATORS OF {{Win32_DiskDrive.DeviceID=\"{diskDrive.DeviceID.Replace(@"\", @"\\")}\"}} WHERE AssocClass = Win32_DiskDriveToDiskPartition"))
{
using (var partitionResults = partitionSearcher.Get())
{
if (partitionResults.Count > 0)
{
var partitions = new List<DiskDrivePartition>(partitionResults.Count);
foreach (var partitionResult in partitionResults.Cast<ManagementObject>())
{
if (partitionResult != null)
{
var partition = new DiskDrivePartition();
partition.DeviceID = (string)partitionResult.GetPropertyValue("DeviceID");
partition.Bootable = (bool?)partitionResult.GetPropertyValue("Bootable");
partition.BootPartition = (bool?)partitionResult.GetPropertyValue("BootPartition");
partition.PrimaryParition = (bool?)partitionResult.GetPropertyValue("PrimaryPartition");
partition.Size = (ulong?)partitionResult.GetPropertyValue("Size");
partition.StartingOffset = (ulong?)partitionResult.GetPropertyValue("StartingOffset");
partition.Type = (string)partitionResult.GetPropertyValue("Type");
using (var logicalSearcher = new ManagementObjectSearcher($"ASSOCIATORS OF {{Win32_DiskPartition.DeviceID=\"{partition.DeviceID}\"}} WHERE AssocClass = Win32_LogicalDiskToPartition"))
{
using (var logicalResults = logicalSearcher.Get())
{
if (logicalResults.Count > 0)
{
foreach (var logicalResult in logicalResults.Cast<ManagementObject>().Take(1))
{
if (logicalResult != null)
{
var logical = new DiskLogical();
logical.DeviceID = (string)logicalResult.GetPropertyValue("DeviceID");
logical.Description = (string)logicalResult.GetPropertyValue("Description");
logical.DriveType = ((DiskLogicalDriveTypes?)(uint?)logicalResult.GetPropertyValue("DriveType")).ToString();
logical.MediaType = ((DiskLogicalMediaTypes?)(uint?)logicalResult.GetPropertyValue("MediaType")).ToString();
logical.FileSystem = (string)logicalResult.GetPropertyValue("FileSystem");
logical.Size = (ulong?)logicalResult.GetPropertyValue("Size");
logical.FreeSpace = (ulong?)logicalResult.GetPropertyValue("FreeSpace");
logical.VolumeName = (string)logicalResult.GetPropertyValue("VolumeName");
logical.VolumeSerialNumber = (string)logicalResult.GetPropertyValue("VolumeSerialNumber");
partition.LogicalDisk = logical;
}
}
}
}
}
partitions.Add(partition);
}
}
diskDrive.Partitions = partitions;
}
}
}
diskDrives.Add(diskDrive);
}
}
deviceHardware.DiskDrives = diskDrives;
}
}
}
}
catch (Exception)
{
// ignore errors to ensure backwards compatibility
}
}
private static void ApplyBatteryInformation(this DeviceHardware deviceHardware)
{
try
{
using (var mSearcher = new ManagementObjectSearcher("SELECT DeviceID, Availability, Chemistry, Description, DesignCapacity, DesignVoltage, FullChargeCapacity, Name FROM Win32_Battery"))
{
using (var mResults = mSearcher.Get())
{
if (mResults.Count > 0)
{
var batteries = new List<Battery>(mResults.Count);
foreach (var mItem in mResults.Cast<ManagementObject>())
{
if (mItem != null)
{
var battery = new Battery();
battery.Availability = ((BatteryAvailability?)(ushort?)mItem.GetPropertyValue("Availability"))?.ToString();
battery.Chemistry = ((BatteryChemistry?)(ushort?)mItem.GetPropertyValue("Chemistry"))?.ToString();
battery.Description = (string)mItem.GetPropertyValue("Description");
battery.DesignCapacity = (uint?)mItem.GetPropertyValue("DesignCapacity");
battery.DeviceID = (string)mItem.GetPropertyValue("DeviceID");
battery.FullChargeCapacity = (uint?)mItem.GetPropertyValue("FullChargeCapacity");
battery.Name = (string)mItem.GetPropertyValue("Name");
batteries.Add(battery);
}
}
deviceHardware.Batteries = batteries;
}
}
}
}
catch (Exception)
{
// ignore errors to ensure backwards compatibility
}
}
private static void ApplyBIOSInformation(this DeviceHardware deviceHardware)
{
try
{
using (var mSearcher = new ManagementObjectSearcher("SELECT BIOSVersion, Manufacturer, ReleaseDate, SerialNumber, SMBIOSBIOSVersion, SMBIOSMajorVersion, SMBIOSMinorVersion, SystemBiosMajorVersion, SystemBiosMinorVersion FROM Win32_BIOS WHERE PrimaryBios=true"))
{
using (var mResults = mSearcher.Get())
{
@@ -61,11 +284,42 @@ namespace Disco.Client.Interop
{
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber");
if (!string.IsNullOrWhiteSpace(serialNumber))
{
DeviceHardware.SerialNumber = serialNumber.Trim();
}
deviceHardware.SerialNumber = serialNumber.Trim();
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
if (deviceHardware.Manufacturer == null && !string.IsNullOrWhiteSpace(manufacturer))
deviceHardware.Manufacturer = manufacturer.Trim();
ErrorReporting.DeviceIdentifier = deviceHardware.SerialNumber;
var biosVersion = (string[])mItem.GetPropertyValue("BIOSVersion");
var releaseDate = default(DateTime?);
var releaseDateString = (string)mItem.GetPropertyValue("ReleaseDate");
if (releaseDateString != null && releaseDateString.Length == 25 && int.TryParse(releaseDateString.Substring(22), out var offsetMinutes))
{
releaseDateString = $"{releaseDateString.Substring(0, 22)}{offsetMinutes / 60:00}:{Math.Abs(offsetMinutes % 60):00}";
if (DateTime.TryParseExact(releaseDateString, "yyyyMMddHHmmss.ffffffzzz", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var releaseDateResult))
releaseDate = releaseDateResult;
}
var sMBIOSBIOSVersion = (string)mItem.GetPropertyValue("SMBIOSBIOSVersion");
var sMBIOSMajorVersion = (ushort?)mItem.GetPropertyValue("SMBIOSMajorVersion");
var sMBIOSMinorVersion = (ushort?)mItem.GetPropertyValue("SMBIOSMinorVersion");
var systemBiosMajorVersion = (byte?)mItem.GetPropertyValue("SystemBiosMajorVersion");
var systemBiosMinorVersion = (byte?)mItem.GetPropertyValue("SystemBiosMinorVersion");
var bios = new Bios()
{
BIOSVersion = biosVersion,
Manufacturer = manufacturer,
ReleaseDate = releaseDate,
SerialNumber = serialNumber,
SMBIOSBIOSVersion = sMBIOSBIOSVersion,
SMBIOSMajorVersion = sMBIOSMajorVersion,
SMBIOSMinorVersion = sMBIOSMinorVersion,
SystemBiosMajorVersion = systemBiosMajorVersion,
SystemBiosMinorVersion = systemBiosMinorVersion,
};
deviceHardware.Bios = new List<Bios>() { bios };
}
else
{
@@ -77,15 +331,15 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve BIOS information from WMI", ex);
throw new Exception("Disco ICT Client was unable to retrieve BIOS information from WMI", ex);
}
}
private static void ApplySystemInformation(this DeviceHardware DeviceHardware)
private static void ApplySystemInformation(this DeviceHardware deviceHardware)
{
try
{
using (var mSearcher = new ManagementObjectSearcher("SELECT Manufacturer, Model, PartOfDomain, PCSystemType, Domain FROM Win32_ComputerSystem"))
using (var mSearcher = new ManagementObjectSearcher("SELECT ChassisSKUNumber, CurrentTimeZone, Description, Manufacturer, Model, OEMStringArray, PCSystemType, PrimaryOwnerContact, PrimaryOwnerName, Roles, SystemSKUNumber, SystemType FROM Win32_ComputerSystem"))
{
using (var mResults = mSearcher.Get())
{
@@ -95,17 +349,40 @@ namespace Disco.Client.Interop
{
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
if (!string.IsNullOrWhiteSpace(manufacturer))
{
DeviceHardware.Manufacturer = manufacturer.Trim();
}
deviceHardware.Manufacturer = manufacturer.Trim();
var model = (string)mItem.GetPropertyValue("Model");
if (!string.IsNullOrWhiteSpace(model))
{
DeviceHardware.Model = model.ToString();
}
deviceHardware.Model = model;
DeviceHardware.ModelType = ((PCSystemTypes)mItem.GetPropertyValue("PCSystemType")).Description();
deviceHardware.ModelType = ((PCSystemTypes)mItem.GetPropertyValue("PCSystemType")).Description();
var chassisSKUNumber = (string)mItem.GetPropertyValue("ChassisSKUNumber");
var currentTimeZone = (short?)mItem.GetPropertyValue("CurrentTimeZone");
var description = (string)mItem.GetPropertyValue("Description");
var oemStringArray = (string[])mItem.GetPropertyValue("OEMStringArray");
var pcSystemType = ((PCSystemTypes)mItem.GetPropertyValue("PCSystemType")).ToString();
var primaryOwnerContact = (string)mItem.GetPropertyValue("PrimaryOwnerContact");
var primaryOwnerName = (string)mItem.GetPropertyValue("PrimaryOwnerName");
var roles = (string[])mItem.GetPropertyValue("Roles");
var systemSKUNumber = (string)mItem.GetPropertyValue("SystemSKUNumber");
var systemType = (string)mItem.GetPropertyValue("SystemType");
var computerSystem = new ComputerSystem()
{
ChassisSKUNumber = chassisSKUNumber,
CurrentTimeZone = currentTimeZone,
Description = description,
OEMStringArray = oemStringArray,
PCSystemType = pcSystemType,
PrimaryOwnerContact = primaryOwnerContact,
PrimaryOwnerName = primaryOwnerName,
Roles = roles,
SystemSKUNumber = systemSKUNumber,
SystemType = systemType,
};
deviceHardware.ComputerSystem = new List<ComputerSystem>() { computerSystem };
}
else
{
@@ -117,11 +394,11 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve ComputerSystem information from WMI", ex);
throw new Exception("Disco ICT Client was unable to retrieve ComputerSystem information from WMI", ex);
}
}
public static void ApplySystemInformation(this Enrol Enrol)
public static void ApplySystemInformation(this Enrol enrol)
{
try
{
@@ -133,11 +410,11 @@ namespace Disco.Client.Interop
{
if (mItem != null)
{
Enrol.IsPartOfDomain = (bool)mItem.GetPropertyValue("PartOfDomain");
if (Enrol.IsPartOfDomain)
enrol.IsPartOfDomain = (bool)mItem.GetPropertyValue("PartOfDomain");
if (enrol.IsPartOfDomain)
{
Enrol.DNSDomainName = (string)mItem.GetPropertyValue("Domain");
enrol.DNSDomainName = (string)mItem.GetPropertyValue("Domain");
}
}
else
@@ -150,52 +427,88 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve ComputerSystem information from WMI", ex);
throw new Exception("Disco ICT Client was unable to retrieve ComputerSystem information from WMI", ex);
}
}
private static void ApplyBaseBoardInformation(this DeviceHardware DeviceHardware)
private static void ApplyBaseBoardInformation(this DeviceHardware deviceHardware)
{
// Added 2012-11-22 G# - Lenovo IdeaPad Serial SHIM
// http://www.discoict.com.au/forum/feature-requests/2012/11/serial-number-detection-on-ideapads.aspx
if (string.IsNullOrWhiteSpace(DeviceHardware.SerialNumber) ||
(DeviceHardware.Manufacturer.Equals("LENOVO", StringComparison.OrdinalIgnoreCase) &&
(DeviceHardware.Model.Equals("S10-3", StringComparison.OrdinalIgnoreCase) // S10-3
|| DeviceHardware.Model.Equals("2957", StringComparison.OrdinalIgnoreCase)))) // S10-2
try
{
try
using (var mSearcher = new ManagementObjectSearcher("SELECT ConfigOptions, Manufacturer, Model, PartNumber, Product, SerialNumber, SKU, Version FROM Win32_BaseBoard"))
{
using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BaseBoard"))
using (var mResults = mSearcher.Get())
{
using (var mResults = mSearcher.Get())
using (var mItem = mResults.Cast<ManagementObject>().FirstOrDefault())
{
using (var mItem = mResults.Cast<ManagementObject>().FirstOrDefault())
if (mItem != null)
{
if (mItem != null)
// Apply Manufacturer/Model information only if not previously found in Win32_ComputerSystem
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
if (deviceHardware.Manufacturer == null && !string.IsNullOrWhiteSpace(manufacturer))
{
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber");
if (!string.IsNullOrWhiteSpace(serialNumber))
{
DeviceHardware.SerialNumber = serialNumber.Trim();
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
}
deviceHardware.Manufacturer = manufacturer.Trim();
}
else
var model = (string)mItem.GetPropertyValue("Model");
if (deviceHardware.Model == null && !string.IsNullOrWhiteSpace(model))
{
throw new Exception("No Win32_BaseBoard was found");
deviceHardware.Model = model;
}
var product = (string)mItem.GetPropertyValue("Product");
if (deviceHardware.Model == null && !string.IsNullOrWhiteSpace(product))
{
deviceHardware.Model = product;
}
// Added 2012-11-22 G# - Lenovo IdeaPad Serial SHIM
// http://www.discoict.com.au/forum/feature-requests/2012/11/serial-number-detection-on-ideapads.aspx
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber");
if (!string.IsNullOrWhiteSpace(serialNumber) &&
(deviceHardware.SerialNumber == null ||
((deviceHardware.Manufacturer?.Equals("LENOVO", StringComparison.OrdinalIgnoreCase) ?? false) &&
((deviceHardware.Model?.Equals("S10-3", StringComparison.OrdinalIgnoreCase) ?? false) // S10-3
|| (deviceHardware.Model?.Equals("2957", StringComparison.OrdinalIgnoreCase) ?? false)))))
{
deviceHardware.SerialNumber = serialNumber.Trim();
ErrorReporting.DeviceIdentifier = deviceHardware.SerialNumber;
}
var configOptions = (string[])mItem.GetPropertyValue("ConfigOptions");
var partNumber = (string)mItem.GetPropertyValue("PartNumber");
var sku = (string)mItem.GetPropertyValue("SKU");
var version = (string)mItem.GetPropertyValue("Version");
var baseBoard = new BaseBoard()
{
ConfigOptions = configOptions,
Manufacturer = manufacturer,
Model = model,
PartNumber = partNumber,
Product = product,
SerialNumber = serialNumber,
SKU = sku,
Version = version,
};
deviceHardware.BasebBoard = new List<BaseBoard>() { baseBoard };
}
else
{
throw new Exception("No Win32_BaseBoard was found");
}
}
}
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve BaseBoard information from WMI", ex);
}
}
catch (Exception ex)
{
throw new Exception("Disco ICT Client was unable to retrieve BaseBoard information from WMI", ex);
}
}
private static void ApplySystemProductInformation(this DeviceHardware DeviceHardware)
private static void ApplySystemProductInformation(this DeviceHardware deviceHardware)
{
try
{
@@ -207,19 +520,31 @@ namespace Disco.Client.Interop
{
if (mItem != null)
{
if (DeviceHardware.SerialNumber == null)
if (deviceHardware.SerialNumber == null)
{
var serialNumber = mItem.GetPropertyValue("IdentifyingNumber") as string;
if (!string.IsNullOrWhiteSpace(serialNumber))
{
DeviceHardware.SerialNumber = serialNumber.Trim();
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
deviceHardware.SerialNumber = serialNumber.Trim();
ErrorReporting.DeviceIdentifier = deviceHardware.SerialNumber;
}
}
var uUID = (string)mItem.GetPropertyValue("UUID");
if (!string.IsNullOrWhiteSpace(uUID))
DeviceHardware.UUID = uUID.Trim();
{
deviceHardware.UUID = uUID.Trim();
// if serial number is absent attempt using UUID if valid
if (string.IsNullOrWhiteSpace(deviceHardware.SerialNumber))
{
Guid uuidGuid;
if (Guid.TryParse(deviceHardware.UUID, out uuidGuid) && uuidGuid != Guid.Empty)
{
deviceHardware.SerialNumber = $"UUID{uuidGuid:N}";
}
}
}
}
else
{
@@ -231,7 +556,7 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve ComputerSystemProduct information from WMI", ex);
throw new Exception("Disco ICT Client was unable to retrieve ComputerSystemProduct information from WMI", ex);
}
}
@@ -273,5 +598,93 @@ namespace Disco.Client.Interop
PerformanceServer,
Maximum
}
private enum ProcessorArchitectures : ushort
{
x86 = 0,
MIPS = 1,
Alpha = 2,
PowerPC = 3,
ia64 = 6,
x64 = 9,
}
private enum DiskLogicalDriveTypes : uint
{
Unknown = 0,
NoRootDirectory,
Removable,
Fixed,
Remote,
CDRom,
RAMDisk,
}
private enum DiskLogicalMediaTypes : uint
{
Unknown = 0,
F5_1Pt2_512,
F3_1Pt44_512,
F3_2Pt88_512,
F3_20Pt8_512,
F3_720_512,
F5_360_512,
F5_320_512,
F5_320_1024,
F5_180_512,
F5_160_512,
RemovableMedia,
FixedMedia,
F3_120M_512,
F3_640_512,
F5_640_512,
F5_720_512,
F3_1Pt2_512,
F3_1Pt23_1024,
F5_1Pt23_1024,
F3_128Mb_512,
F3_230Mb_512,
F8_256_128,
F3_200Mb_512,
F3_240M_512,
F3_32M_512,
}
private enum BatteryAvailability : ushort
{
Other = 1,
Unknown = 2,
RunningFullPower = 3,
Warning = 4,
InTest = 5,
NotApplicable = 6,
PowerOff = 7,
OffLine = 8,
OffDuty = 9,
Degraded = 10,
NotInstalled = 11,
InstallError = 12,
PowerSaveUnknown = 13,
PowerSaveLowPowerMode = 14,
PowerSaveStandby = 15,
PowerCycle = 16,
PowerSaveWarning = 17,
Paused = 18,
NotReady = 19,
NotConfigured = 20,
Quiesced = 21,
}
private enum BatteryChemistry : ushort
{
Other = 1,
Unknown = 2,
LeadAcid = 3,
NickelCadmium = 4,
NickelMetalHydride = 5,
LithiumIon = 6,
ZincAir = 7,
LithiumPolymer = 8,
}
}
}
+1 -1
View File
@@ -68,7 +68,7 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve NetworkAdapter information from WMI", ex);
throw new Exception("Disco ICT Client was unable to retrieve NetworkAdapter information from WMI", ex);
}
}
+3 -3
View File
@@ -61,7 +61,7 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve Wireless NetworkAdapter information from WlanApi", ex);
throw new Exception("Disco ICT Client was unable to retrieve Wireless NetworkAdapter information from WlanApi", ex);
}
}
@@ -102,7 +102,7 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to retrieve Wireless Profiles from WlanApi", ex);
throw new Exception("Disco ICT Client was unable to retrieve Wireless Profiles from WlanApi", ex);
}
}
@@ -356,7 +356,7 @@ namespace Disco.Client.Interop
}
catch (Exception ex)
{
throw new Exception("Disco Client was unable to apply Wireless Profile Changes using WlanApi", ex);
throw new Exception("Disco ICT Client was unable to apply Wireless Profile Changes using WlanApi", ex);
}
}
+3 -3
View File
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.16320.1300")]
[assembly: AssemblyFileVersion("2.2.16320.1300")]
[assembly: AssemblyVersion("2.3.23161.0650")]
[assembly: AssemblyFileVersion("2.3.23161.0650")]
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net40-Client" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net40-client" />
</packages>
+12 -12
View File
@@ -20,13 +20,13 @@ namespace Disco.ClientBootstrapper
private StringBuilder errorMessage;
private Process clientProcess;
#if DEBUG
public const string DiscoServerName = "WS-GSHARP";
public const int DiscoServerPort = 57252;
#else
//#if DEBUG
// public const string DiscoServerName = "WS-GSHARP";
// public const int DiscoServerPort = 57252;
//#else
public const string DiscoServerName = "DISCO";
public const int DiscoServerPort = 9292;
#endif
//#endif
public BootstrapperLoop(IStatus StatusUI, LoopCompleteCallback Callback)
{
@@ -85,12 +85,12 @@ namespace Disco.ClientBootstrapper
// Check for Network Connectivity
statusUI.UpdateStatus(null, "Detecting Network", "Checking network connectivity, Please wait...", true, -1);
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
{
statusUI.UpdateStatus(null, "Detecting Network", "No network connectivity detected, Diagnosing...", true, -1);
statusUI_WriteAdapterInfo();
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
{
// Check for Wireless
var hasWireless = (Interop.NetworkInterop.NetworkAdapters.Count(na => na.IsWireless) > 0);
@@ -105,17 +105,17 @@ namespace Disco.ClientBootstrapper
statusUI_WriteAdapterInfo();
statusUI.UpdateStatus(null, null, null, true, i);
Program.SleepThread(500, false);
if (Interop.NetworkInterop.PingDisco(DiscoServerName))
if (Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
break;
}
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
{
statusUI.UpdateStatus(null, "Wireless Network Failed", "Unable to connect to the wireless network, please connect the network cable...", false);
Program.SleepThread(3000, false);
}
}
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
{
// Instruct user to connect network cable
statusUI.UpdateStatus(null, "Please connect the network cable", null);
@@ -124,13 +124,13 @@ namespace Disco.ClientBootstrapper
statusUI_WriteAdapterInfo();
statusUI.UpdateStatus(null, null, null, true, i);
Program.SleepThread(500, false);
if (Interop.NetworkInterop.PingDisco(DiscoServerName))
if (Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
break;
}
}
}
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
{
// Client Failed
if (this.mLoopCompleteCallback != null)
@@ -8,4 +8,4 @@ BootstrapperLocation = Mid(WScript.ScriptFullName, 1, InStrRev(WScript.ScriptFul
Call objShell.Run("""" & BootstrapperLocation & """ /Install", , True)
WScript.Echo "Disco Client Bootstrapper Installed"
WScript.Echo "Disco ICT Client Bootstrapper Installed"
@@ -10,8 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco.ClientBootstrapper</RootNamespace>
<AssemblyName>Disco.ClientBootstrapper</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
+2 -2
View File
@@ -85,7 +85,7 @@
this.labelVersion.Name = "labelVersion";
this.labelVersion.Size = new System.Drawing.Size(167, 20);
this.labelVersion.TabIndex = 0;
this.labelVersion.Text = "Disco Bootstrapper v";
this.labelVersion.Text = "Disco ICT Bootstrapper v";
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// FormStatus
@@ -106,7 +106,7 @@
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Disco - Client Bootstrapper";
this.Text = "Disco ICT - Client Bootstrapper";
this.TopMost = true;
this.TransparencyKey = System.Drawing.Color.Magenta;
this.ResumeLayout(false);
@@ -16,8 +16,9 @@ namespace Disco.ClientBootstrapper.Interop
if (_tempCerts != null && _tempCerts.Count > 0)
{
Remove(StoreName.My, StoreLocation.LocalMachine, _tempCerts);
Remove(StoreName.CertificateAuthority, StoreLocation.LocalMachine, _tempCerts);
Remove(StoreName.Root, StoreLocation.LocalMachine, _tempCerts);
// dont remove root/intermediate certs as they may be have installed by client
//Remove(StoreName.CertificateAuthority, StoreLocation.LocalMachine, _tempCerts);
//Remove(StoreName.Root, StoreLocation.LocalMachine, _tempCerts);
}
}
public static void AddTempCerts()
@@ -106,7 +107,26 @@ namespace Disco.ClientBootstrapper.Interop
public static string ShortSubjectName(this X509Certificate2 Certificate)
{
string s = Certificate.Subject;
return s.Substring(s.IndexOf("=") + 1, s.IndexOf(",") - s.IndexOf("=") - 1);
if (string.IsNullOrWhiteSpace(s))
{
return $"Unknown Certificate: {Certificate.Thumbprint}";
}
else
{
if (s.Length > 3 && s.StartsWith("CN=", StringComparison.OrdinalIgnoreCase))
{
var nameLength = s.IndexOf(',') - 3;
if (nameLength > 0)
{
return s.Substring(3, nameLength);
}
else
{
return s.Substring(3);
}
}
return s;
}
}
public static bool Add(StoreName StoreName, StoreLocation StoreLocation, X509Certificate2 Certificate)
@@ -165,7 +165,7 @@ namespace Disco.ClientBootstrapper.Interop
}
}
public static bool PingDisco(string ServerName)
public static bool PingDiscoIct(string ServerName)
{
using (Ping p = new Ping())
{
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.16320.1300")]
[assembly: AssemblyFileVersion("2.2.16320.1300")]
[assembly: AssemblyVersion("2.3.23161.0650")]
[assembly: AssemblyFileVersion("2.3.23161.0650")]
+2 -2
View File
@@ -15,6 +15,6 @@
</defaultConnectionFactory>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
</configuration>
</configuration>
@@ -34,11 +34,11 @@ namespace Disco.Data.Configuration
private void SetValue<T>(string Key, T Value)
{
ConfigurationCache.SetValue(Database, this.Scope, Key, Value);
ConfigurationCache.Helpers<T>.SetValue(Database, this.Scope, Key, Value);
}
private T GetValue<T>(string Key, T Default)
{
return ConfigurationCache.GetValue(Database, this.Scope, Key, Default);
return ConfigurationCache.Helpers<T>.GetValue(Database, this.Scope, Key, Default);
}
protected void Set<T>(T Value, [CallerMemberName] string Key = null)
+74 -68
View File
@@ -202,89 +202,95 @@ namespace Disco.Data.Configuration
#endregion
#region Cache Getters/Setters
internal static T GetValue<T>(DiscoDataContext Database, string Scope, string Key, T Default)
internal static class Helpers<T>
{
var item = CacheGetItem(Database, Scope, Key);
private static readonly IEqualityComparer<T> comparer = EqualityComparer<T>.Default;
if (item == null)
return Default;
else
internal static T GetValue(DiscoDataContext Database, string Scope, string Key, T Default)
{
if (item.Item2 != null && item.Item2.GetType() == typeof(T))
{
// Return Cached Item
return (T)item.Item2;
}
var item = CacheGetItem(Database, Scope, Key);
if (item == null)
return Default;
else
{
// Convert Serialized Item
Type itemType = typeof(T);
object itemValue;
if (itemType == typeof(string))
if (item.Item2 != null && item.Item2.GetType() == typeof(T))
{
// string
itemValue = item.Item1.Value;
}
else if (itemType == typeof(object))
{
// object
itemValue = item.Item1.Value;
}
else if (IsConvertableFromString(itemType))
{
// IConvertable
itemValue = Convert.ChangeType(item.Item1.Value, itemType);
}
else if (itemType.BaseType != null && itemType.BaseType == typeof(Enum))
{
// Enum
itemValue = Enum.Parse(typeof(T), item.Item1.Value);
// Return Cached Item
return (T)item.Item2;
}
else
{
// JSON Deserialize
itemValue = JsonConvert.DeserializeObject<T>(item.Item1.Value);
// Convert Serialized Item
Type itemType = typeof(T);
object itemValue;
if (itemType == typeof(string))
{
// string
itemValue = item.Item1.Value;
}
else if (itemType == typeof(object))
{
// object
itemValue = item.Item1.Value;
}
else if (IsConvertableFromString(itemType))
{
// IConvertable
itemValue = Convert.ChangeType(item.Item1.Value, itemType);
}
else if (itemType.BaseType != null && itemType.BaseType == typeof(Enum))
{
// Enum
itemValue = Enum.Parse(typeof(T), item.Item1.Value);
}
else
{
// JSON Deserialize
itemValue = JsonConvert.DeserializeObject<T>(item.Item1.Value);
}
// Set Item in Cache
SetItemTypeValue(item, itemValue);
return (T)itemValue;
}
// Set Item in Cache
SetItemTypeValue(item, itemValue);
return (T)itemValue;
}
}
}
internal static void SetValue<T>(DiscoDataContext Database, string Scope, string Key, T Value)
{
Type valueType = typeof(T);
string stringValue;
internal static void SetValue(DiscoDataContext Database, string Scope, string Key, T Value)
{
Type valueType = typeof(T);
string stringValue;
if (Value == null)
{
stringValue = null;
}
else if (valueType == typeof(object))
{
throw new ArgumentException(string.Format("Cannot serialize the configuration item [{0}].[{1}] which defines a type of [System.Object]", Scope, Key), "Value");
}
else if (IsConvertableFromString(valueType))
{
// string or supports IConvertable
stringValue = Value.ToString();
}
else if (valueType.BaseType != null && valueType.BaseType == typeof(Enum))
{
// Enum
stringValue = Value.ToString();
}
else
{
// JSON Serialize
stringValue = JsonConvert.SerializeObject(Value);
}
if (comparer.Equals(Value, default(T)))
{
stringValue = null;
}
else if (valueType == typeof(object))
{
throw new ArgumentException(string.Format("Cannot serialize the configuration item [{0}].[{1}] which defines a type of [System.Object]", Scope, Key), "Value");
}
else if (IsConvertableFromString(valueType))
{
// string or supports IConvertable
stringValue = Value.ToString();
}
else if (valueType.BaseType != null && valueType.BaseType == typeof(Enum))
{
// Enum
stringValue = Value.ToString();
}
else
{
// JSON Serialize
stringValue = JsonConvert.SerializeObject(Value);
}
CacheSetItem(Database, Scope, Key, stringValue, Value);
CacheSetItem(Database, Scope, Key, stringValue, Value);
}
}
#endregion
#region Cache Helpers
@@ -1,5 +1,7 @@
using Disco.Data.Repository;
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace Disco.Data.Configuration.Modules
{
@@ -24,12 +26,36 @@ namespace Disco.Data.Configuration.Modules
}
}
[Obsolete("User SearchAllServers instead"), EditorBrowsable(EditorBrowsableState.Never)]
public bool? SearchAllForestServers
{
get { return Get<bool?>(null); }
set { Set(value); }
}
public bool? SearchAllServers
{
get {
var value = Get<bool?>(null);
/// migrate <see cref="SearchAllForestServers"/>
#pragma warning disable CS0618 // Type or member is obsolete
if (value == null)
{
value = SearchAllForestServers;
if (value != null)
{
SearchAllForestServers = null;
SearchAllServers = value;
}
}
#pragma warning restore CS0618 // Type or member is obsolete
return value;
}
set { Set(value); }
}
/// <summary>
/// If true LDAP filters contain wildcards only at the end of the search term.
/// This greatly improves performance in very large AD environments (ie: EDU001/EDU002)
@@ -150,6 +150,15 @@ namespace Disco.Data.Configuration
return System.IO.Path.Combine(DataStoreLocation, @"PluginPackages\");
}
}
public string PluginUserPhotosLocation
=> Path.Combine(DataStoreLocation, @"PluginUserPhotos\");
public DateTime PluginDetailsCacheExpiration
{
get => Get(DateTime.MinValue);
set => Set(value);
}
#endregion
#region Organisation Details
@@ -271,6 +280,44 @@ namespace Disco.Data.Configuration
}
#endregion
#region Email Configuration
public string EmailSmtpServer
{
get => Get<string>(null);
set => Set(value);
}
public int EmailSmtpPort
{
get => Get(25);
set => Set(value);
}
public bool EmailEnableSsl
{
get => Get(false);
set => Set(value);
}
public string EmailFromAddress
{
get => Get<string>(null);
set => Set(value);
}
public string EmailReplyToAddress
{
get => Get<string>(null);
set => Set(value);
}
public string EmailUsername
{
get => Get<string>(null);
set => Set(value);
}
public string EmailPassword
{
get => GetDeobsfucated(null);
set => SetObsfucated(value);
}
#endregion
#region UpdateCheck
public string DeploymentId
{
+36 -3
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco.Data</RootNamespace>
<AssemblyName>Disco.Data</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
@@ -40,8 +40,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
@@ -163,6 +163,22 @@
<Compile Include="Migrations\201611100557315_DBv19.Designer.cs">
<DependentUpon>201611100557315_DBv19.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202011260525547_DBv20.cs" />
<Compile Include="Migrations\202011260525547_DBv20.Designer.cs">
<DependentUpon>202011260525547_DBv20.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202102110443550_DBv21.cs" />
<Compile Include="Migrations\202102110443550_DBv21.Designer.cs">
<DependentUpon>202102110443550_DBv21.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202304150715559_DBv22.cs" />
<Compile Include="Migrations\202304150715559_DBv22.Designer.cs">
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202401130531317_DBv23.cs" />
<Compile Include="Migrations\202401130531317_DBv23.Designer.cs">
<DependentUpon>202401130531317_DBv23.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Migrations\DiscoDataMigrator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -235,6 +251,18 @@
<EmbeddedResource Include="Migrations\201611100557315_DBv19.resx">
<DependentUpon>201611100557315_DBv19.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202011260525547_DBv20.resx">
<DependentUpon>202011260525547_DBv20.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202102110443550_DBv21.resx">
<DependentUpon>202102110443550_DBv21.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202304150715559_DBv22.resx">
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202401130531317_DBv23.resx">
<DependentUpon>202401130531317_DBv23.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -246,6 +274,11 @@
<None Include="Resources\EmptyLogo.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv20 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv20));
string IMigrationMetadata.Id
{
get { return "202011260525547_DBv20"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,39 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv20 : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.DeviceBatchAttachments",
c => new
{
Id = c.Int(nullable: false, identity: true),
DeviceBatchId = c.Int(nullable: false),
TechUserId = c.String(nullable: false, maxLength: 50),
Filename = c.String(nullable: false, maxLength: 500),
MimeType = c.String(nullable: false, maxLength: 500),
Timestamp = c.DateTime(nullable: false),
Comments = c.String(nullable: false, maxLength: 500),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.DeviceBatches", t => t.DeviceBatchId)
.ForeignKey("dbo.Users", t => t.TechUserId)
.Index(t => t.DeviceBatchId)
.Index(t => t.TechUserId);
}
public override void Down()
{
DropIndex("dbo.DeviceBatchAttachments", new[] { "TechUserId" });
DropIndex("dbo.DeviceBatchAttachments", new[] { "DeviceBatchId" });
DropForeignKey("dbo.DeviceBatchAttachments", "TechUserId", "dbo.Users");
DropForeignKey("dbo.DeviceBatchAttachments", "DeviceBatchId", "dbo.DeviceBatches");
DropTable("dbo.DeviceBatchAttachments");
}
}
}
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv21 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv21));
string IMigrationMetadata.Id
{
get { return "202102110443550_DBv21"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,34 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv21 : DbMigration
{
public override void Up()
{
AddColumn("dbo.UserAttachments", "HandlerId", c => c.String(maxLength: 30));
AddColumn("dbo.UserAttachments", "HandlerReferenceId", c => c.String(maxLength: 50));
AddColumn("dbo.UserAttachments", "HandlerData", c => c.String());
AddColumn("dbo.JobAttachments", "HandlerId", c => c.String(maxLength: 30));
AddColumn("dbo.JobAttachments", "HandlerReferenceId", c => c.String(maxLength: 50));
AddColumn("dbo.JobAttachments", "HandlerData", c => c.String());
AddColumn("dbo.DeviceAttachments", "HandlerId", c => c.String(maxLength: 30));
AddColumn("dbo.DeviceAttachments", "HandlerReferenceId", c => c.String(maxLength: 50));
AddColumn("dbo.DeviceAttachments", "HandlerData", c => c.String());
}
public override void Down()
{
DropColumn("dbo.DeviceAttachments", "HandlerData");
DropColumn("dbo.DeviceAttachments", "HandlerReferenceId");
DropColumn("dbo.DeviceAttachments", "HandlerId");
DropColumn("dbo.JobAttachments", "HandlerData");
DropColumn("dbo.JobAttachments", "HandlerReferenceId");
DropColumn("dbo.JobAttachments", "HandlerId");
DropColumn("dbo.UserAttachments", "HandlerData");
DropColumn("dbo.UserAttachments", "HandlerReferenceId");
DropColumn("dbo.UserAttachments", "HandlerId");
}
}
}
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv22 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv22));
string IMigrationMetadata.Id
{
get { return "202304150715559_DBv22"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,18 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv22 : DbMigration
{
public override void Up()
{
AddColumn("dbo.DocumentTemplates", "OnImportUserFlagRules", c => c.String());
}
public override void Down()
{
DropColumn("dbo.DocumentTemplates", "OnImportUserFlagRules");
}
}
}
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv23 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv23));
string IMigrationMetadata.Id
{
get { return "202401130531317_DBv23"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,67 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv23 : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.DeviceFlagAssignments",
c => new
{
Id = c.Int(nullable: false, identity: true),
DeviceFlagId = c.Int(nullable: false),
DeviceSerialNumber = c.String(nullable: false, maxLength: 60),
AddedDate = c.DateTime(nullable: false),
AddedUserId = c.String(nullable: false, maxLength: 50),
RemovedDate = c.DateTime(),
RemovedUserId = c.String(maxLength: 50),
Comments = c.String(),
OnAssignmentExpressionResult = c.String(),
OnUnassignmentExpressionResult = c.String(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.DeviceFlags", t => t.DeviceFlagId)
.ForeignKey("dbo.Devices", t => t.DeviceSerialNumber)
.ForeignKey("dbo.Users", t => t.AddedUserId)
.ForeignKey("dbo.Users", t => t.RemovedUserId)
.Index(t => t.DeviceFlagId)
.Index(t => t.DeviceSerialNumber)
.Index(t => t.AddedUserId)
.Index(t => t.RemovedUserId);
CreateTable(
"dbo.DeviceFlags",
c => new
{
Id = c.Int(nullable: false, identity: true),
Name = c.String(nullable: false, maxLength: 100),
Description = c.String(maxLength: 500),
Icon = c.String(nullable: false, maxLength: 25),
IconColour = c.String(nullable: false, maxLength: 10),
DevicesLinkedGroup = c.String(),
DeviceUsersLinkedGroup = c.String(),
OnAssignmentExpression = c.String(),
OnUnassignmentExpression = c.String(),
})
.PrimaryKey(t => t.Id);
}
public override void Down()
{
DropIndex("dbo.DeviceFlagAssignments", new[] { "RemovedUserId" });
DropIndex("dbo.DeviceFlagAssignments", new[] { "AddedUserId" });
DropIndex("dbo.DeviceFlagAssignments", new[] { "DeviceSerialNumber" });
DropIndex("dbo.DeviceFlagAssignments", new[] { "DeviceFlagId" });
DropForeignKey("dbo.DeviceFlagAssignments", "RemovedUserId", "dbo.Users");
DropForeignKey("dbo.DeviceFlagAssignments", "AddedUserId", "dbo.Users");
DropForeignKey("dbo.DeviceFlagAssignments", "DeviceSerialNumber", "dbo.Devices");
DropForeignKey("dbo.DeviceFlagAssignments", "DeviceFlagId", "dbo.DeviceFlags");
DropTable("dbo.DeviceFlags");
DropTable("dbo.DeviceFlagAssignments");
}
}
}
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.16320.1300")]
[assembly: AssemblyFileVersion("2.2.16320.1300")]
[assembly: AssemblyVersion("2.3.23161.0650")]
[assembly: AssemblyFileVersion("2.3.23161.0650")]
+2 -2
View File
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -19,7 +19,7 @@ namespace Disco.Data.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
+6 -5
View File
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.Repository;
using System;
using System.Data.Entity;
using Disco.Models.Repository;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace Disco.Data.Repository
@@ -22,6 +19,7 @@ namespace Disco.Data.Repository
public virtual DbSet<DocumentTemplate> DocumentTemplates { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<UserDetail> UserDetails { get; set; }
public virtual DbSet<UserAttachment> UserAttachments { get; set; }
public virtual DbSet<UserFlag> UserFlags { get; set; }
public virtual DbSet<UserFlagAssignment> UserFlagAssignments { get; set; }
@@ -34,8 +32,11 @@ namespace Disco.Data.Repository
public virtual DbSet<DeviceModel> DeviceModels { get; set; }
public virtual DbSet<DeviceProfile> DeviceProfiles { get; set; }
public virtual DbSet<DeviceBatch> DeviceBatches { get; set; }
public virtual DbSet<DeviceBatchAttachment> DeviceBatchAttachments { get; set; }
public virtual DbSet<DeviceComponent> DeviceComponents { get; set; }
public virtual DbSet<DeviceAttachment> DeviceAttachments { get; set; }
public virtual DbSet<DeviceFlag> DeviceFlags { get; set; }
public virtual DbSet<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
public virtual DbSet<DeviceCertificate> DeviceCertificates { get; set; }
+12 -14
View File
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.Repository;
using Disco.Models.Repository;
using System;
using System.Data.SqlClient;
using System.DirectoryServices.ActiveDirectory;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
using System.Linq;
namespace Disco.Data.Repository
{
@@ -370,7 +368,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
string defaultNamingContext;
using (Domain d = Domain.GetComputerDomain())
{
string ldapPath = string.Format("LDAP://{0}/", d.Name);
string ldapPath = $"LDAP://{d.Name}/";
string configurationNamingContext;
using (var adRootDSE = new DirectoryEntry(ldapPath + "RootDSE"))
@@ -381,7 +379,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
using (var configSearchRoot = new DirectoryEntry(ldapPath + "CN=Partitions," + configurationNamingContext))
{
var configSearchFilter = string.Format("(&(objectcategory=Crossref)(dnsRoot={0})(netBIOSName=*))", d.Name);
var configSearchFilter = $"(&(objectcategory=Crossref)(dnsRoot={d.Name})(netBIOSName=*))";
var configSearchLoadProperites = new string[] { "NetBIOSName" };
using (var configSearcher = new DirectorySearcher(configSearchRoot, configSearchFilter, configSearchLoadProperites, SearchScope.OneLevel))
@@ -403,14 +401,14 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
// Authorization Roles
foreach (var authRole in Database.AuthorizationRoles.Where(ar => ar.SubjectIds != null).ToList())
{
var ids = string.Join(",", authRole.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : string.Format("{0}\\{1}", netBiosName, id)));
var ids = string.Join(",", authRole.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : $@"{netBiosName}\{id}"));
if (ids != authRole.SubjectIds)
authRole.SubjectIds = ids;
}
// Job Queues
foreach (var jobQueue in Database.JobQueues.Where(jq => jq.SubjectIds != null).ToList())
{
var ids = string.Join(",", jobQueue.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : string.Format("{0}\\{1}", netBiosName, id)));
var ids = string.Join(",", jobQueue.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : $@"{netBiosName}\{id}"));
if (ids != jobQueue.SubjectIds)
jobQueue.SubjectIds = ids;
}
@@ -418,9 +416,9 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
foreach (var deviceProfile in Database.DeviceProfiles.Where(dp => dp.OrganisationalUnit == null || !dp.OrganisationalUnit.Contains(@"DC=")).ToList())
{
if (string.IsNullOrWhiteSpace(deviceProfile.OrganisationalUnit))
deviceProfile.OrganisationalUnit = string.Format("CN=Computers,{0}", defaultNamingContext);
deviceProfile.OrganisationalUnit = $"CN=Computers,{defaultNamingContext}";
else
deviceProfile.OrganisationalUnit = string.Format("{0},{1}", deviceProfile.OrganisationalUnit, defaultNamingContext);
deviceProfile.OrganisationalUnit = $"{deviceProfile.OrganisationalUnit},{defaultNamingContext}";
}
Database.SaveChanges();
@@ -451,7 +449,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
// MIGRATE DEVICES
foreach (var device in Database.Devices.Where(d => d.DeviceDomainId != null && !d.DeviceDomainId.Contains(@"\")).ToList())
{
device.DeviceDomainId = string.Format("{0}\\{1}", netBiosName, device.DeviceDomainId);
device.DeviceDomainId = $@"{netBiosName}\{device.DeviceDomainId}";
}
Database.SaveChanges();
@@ -462,7 +460,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
idExisting.Value = user.UserId;
SqlParameter idNew = new SqlParameter("@IdNew", System.Data.SqlDbType.NVarChar, 50);
idNew.Value = string.Format("{0}\\{1}", netBiosName, user.UserId);
idNew.Value = $@"{netBiosName}\{user.UserId}";
Database.Database.ExecuteSqlCommand(MigratePreDomainUsers_Sql, idExisting, idNew);
}
@@ -71,7 +71,7 @@ namespace Disco.Data.Repository
var connectionString = DiscoDataContextConnectionString;
if (connectionString == null)
{
throw new InvalidOperationException("The Disco DataContext Connection String has not been configured");
throw new InvalidOperationException("The Disco ICT DataContext Connection String has not been configured");
}
// Build DiscoDataContext - Use Default Connection Factory (SQLClient)
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net45" />
<package id="Rx-Core" version="2.2.5" targetFramework="net45" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
<package id="Rx-Linq" version="2.2.5" targetFramework="net45" />
+2 -2
View File
@@ -12,6 +12,6 @@
</defaultConnectionFactory>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
</configuration>
</configuration>
@@ -0,0 +1,14 @@
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class BaseBoard
{
public string[] ConfigOptions { get; set; }
public string Manufacturer { get; set; }
public string Model { get; set; }
public string PartNumber { get; set; }
public string Product { get; set; }
public string SerialNumber { get; set; }
public string SKU { get; set; }
public string Version { get; set; }
}
}
@@ -0,0 +1,14 @@
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class Battery
{
public string Availability { get; set; }
public string Chemistry { get; set; }
public string Description { get; set; }
public uint? DesignCapacity { get; set; }
public ulong? DesignVoltage { get; set; }
public string DeviceID { get; set; }
public uint? FullChargeCapacity { get; set; }
public string Name { get; set; }
}
}
@@ -0,0 +1,17 @@
using System;
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class Bios
{
public string[] BIOSVersion { get; set; }
public string Manufacturer { get; set; }
public DateTime? ReleaseDate { get; set; }
public string SerialNumber { get; set; }
public string SMBIOSBIOSVersion { get; set; }
public ushort? SMBIOSMajorVersion { get; set; }
public ushort? SMBIOSMinorVersion { get; set; }
public byte? SystemBiosMajorVersion { get; set; }
public byte? SystemBiosMinorVersion { get; set; }
}
}
@@ -0,0 +1,16 @@
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class ComputerSystem
{
public string ChassisSKUNumber { get; set; }
public short? CurrentTimeZone { get; set;}
public string Description { get; set; }
public string[] OEMStringArray { get; set; }
public string PCSystemType { get; set; }
public string PrimaryOwnerContact { get; set; }
public string PrimaryOwnerName { get; set; }
public string[] Roles { get; set; }
public string SystemSKUNumber { get; set; }
public string SystemType { get; set; }
}
}
@@ -11,10 +11,13 @@ namespace Disco.Models.ClientServices.EnrolmentInformation
public string Model { get; set; }
public string ModelType { get; set; }
public List<Bios> Bios { get; set; }
public List<BaseBoard> BasebBoard { get; set; }
public List<ComputerSystem> ComputerSystem { get; set; }
public List<Processor> Processors { get; set; }
public List<PhysicalMemory> PhysicalMemory { get; set; }
public List<DiskDrive> DiskDrives { get; set; }
public List<NetworkAdapter> NetworkAdapters { get; set; }
public List<Battery> Batteries { get; set; }
}
}
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace Disco.Models.ClientServices.EnrolmentInformation
{
@@ -12,8 +11,7 @@ namespace Disco.Models.ClientServices.EnrolmentInformation
public string InterfaceType { get; set; }
public string SerialNumber { get; set; }
public string FirmwareRevision { get; set; }
public DateTime InstallDate { get; set; }
public ulong Size { get; set; }
public ulong? Size { get; set; }
public List<DiskDrivePartition> Partitions { get; set; }
}
@@ -1,16 +1,15 @@
using System.Collections.Generic;
namespace Disco.Models.ClientServices.EnrolmentInformation
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class DiskDrivePartition
{
public bool DeviceID { get; set; }
public bool Bootable { get; set; }
public bool BootPartition { get; set; }
public bool PrimaryParition { get; set; }
public ulong Size { get; set; }
public ulong StartingOffset { get; set; }
public string DeviceID { get; set; }
public bool? Bootable { get; set; }
public bool? BootPartition { get; set; }
public bool? PrimaryParition { get; set; }
public ulong? Size { get; set; }
public ulong? StartingOffset { get; set; }
public string Type { get; set; }
public List<DiskLogical> LogicalDisks { get; set; }
public DiskLogical LogicalDisk { get; set; }
}
}
@@ -1,23 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.ClientServices.EnrolmentInformation
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class DiskLogical
{
public string DeviceID { get; set; }
public string Description { get; set; }
public int DriveType { get; set; }
public int MediaType { get; set; }
public string DriveType { get; set; }
public string MediaType { get; set; }
public string FileSystem { get; set; }
public ulong Size { get; set; }
public ulong FreeSpace { get; set; }
public ulong? Size { get; set; }
public ulong? FreeSpace { get; set; }
public string VolumeName { get; set; }
public string VolumeSerialNumber { get; set; }
}
}
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.ClientServices.EnrolmentInformation
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class PhysicalMemory
{
@@ -13,11 +7,10 @@ namespace Disco.Models.ClientServices.EnrolmentInformation
public string Manufacturer { get; set; }
public string PartNumber { get; set; }
public ulong Capacity { get; set; }
public int ClockSpeed { get; set; }
public int Voltage { get; set; }
public string Location { get; set; }
public ulong? Capacity { get; set; }
public uint? ConfiguredClockSpeed { get; set; }
public uint? Speed { get; set; }
public string DeviceLocator { get; set; }
}
}
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.ClientServices.EnrolmentInformation
namespace Disco.Models.ClientServices.EnrolmentInformation
{
public class Processor
{
@@ -13,9 +7,9 @@ namespace Disco.Models.ClientServices.EnrolmentInformation
public string Name { get; set; }
public string Description { get; set; }
public string Architecture { get; set; }
public short Family { get; set; }
public int MaxClockSpeed { get; set; }
public int NumberOfCores { get; set; }
public int NumberOfLogicalProcessors { get; set; }
public ushort? Family { get; set; }
public uint? MaxClockSpeed { get; set; }
public uint? NumberOfCores { get; set; }
public uint? NumberOfLogicalProcessors { get; set; }
}
}
+42 -5
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco.Models</RootNamespace>
<AssemblyName>Disco.Models</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
@@ -34,8 +34,8 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
@@ -49,6 +49,18 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BI\Config\OrganisationAddress.cs" />
<Compile Include="Exporting\ExportFieldMetadata.cs" />
<Compile Include="Exporting\ExportFormat.cs" />
<Compile Include="Exporting\IExportRecord.cs" />
<Compile Include="Repository\Device\Flag\DeviceFlag.cs" />
<Compile Include="Repository\Device\Flag\DeviceFlagAssignment.cs" />
<Compile Include="Services\Devices\DeviceFlags\DeviceFlagExportOptions.cs" />
<Compile Include="Services\Devices\DeviceFlags\DeviceFlagExportRecord.cs" />
<Compile Include="Services\Expressions\Extensions\ImageExpressionFormat.cs" />
<Compile Include="ClientServices\EnrolmentInformation\BaseBoard.cs" />
<Compile Include="ClientServices\EnrolmentInformation\Battery.cs" />
<Compile Include="ClientServices\EnrolmentInformation\Bios.cs" />
<Compile Include="ClientServices\EnrolmentInformation\ComputerSystem.cs" />
<Compile Include="ClientServices\EnrolmentInformation\DiskLogical.cs" />
<Compile Include="ClientServices\EnrolmentInformation\DeviceHardware.cs" />
<Compile Include="ClientServices\EnrolmentInformation\DiskDrive.cs" />
@@ -60,7 +72,14 @@
<Compile Include="ClientServices\EnrolmentInformation\WirelessProfile.cs" />
<Compile Include="ClientServices\EnrolmentInformation\WirelessProfileStore.cs" />
<Compile Include="ClientServices\EnrolmentInformation\WirelessProfileTransformation.cs" />
<Compile Include="Repository\Device\DeviceBatchAttachment.cs" />
<Compile Include="Services\Devices\Importing\IDeviceImportColumn.cs" />
<Compile Include="Services\Devices\Importing\IDeviceImportDataReader.cs" />
<Compile Include="Services\Documents\DocumentField.cs" />
<Compile Include="Services\Documents\DocumentFieldType.cs" />
<Compile Include="Services\Documents\DocumentTemplatePackage.cs" />
<Compile Include="Services\Documents\OnImportUserFlagRule.cs" />
<Compile Include="Exporting\IExportOptions.cs" />
<Compile Include="Services\Jobs\LocationModes.cs" />
<Compile Include="ClientServices\EnrolmentInformation\Certificate.cs" />
<Compile Include="ClientServices\Register.cs" />
@@ -75,7 +94,7 @@
<Compile Include="Services\Authorization\IClaimNavigatorItem.cs" />
<Compile Include="Services\Authorization\IRoleToken.cs" />
<Compile Include="Services\Documents\DocumentState.cs" />
<Compile Include="BI\Expressions\IImageExpressionResult.cs" />
<Compile Include="Services\Expressions\Extensions\IImageExpressionResult.cs" />
<Compile Include="Services\Jobs\Statistics\DailyOpenedClosedItem.cs" />
<Compile Include="ClientServices\EnrolResponse.cs" />
<Compile Include="ClientServices\MacEnrol.cs" />
@@ -114,7 +133,7 @@
<Compile Include="Repository\User\UserDetail.cs" />
<Compile Include="Repository\User\AuthorizationRole.cs" />
<Compile Include="Services\Devices\Exporting\DeviceExportRecord.cs" />
<Compile Include="Services\Devices\Exporting\DeviceExportResult.cs" />
<Compile Include="Exporting\ExportResult.cs" />
<Compile Include="Services\Devices\Exporting\DeviceExportTypes.cs" />
<Compile Include="Services\Devices\Exporting\DeviceExportOptions.cs" />
<Compile Include="Services\Devices\Importing\DeviceImportFieldTypes.cs" />
@@ -135,10 +154,16 @@
<Compile Include="Services\Jobs\JobLists\JobTableStatusQueueItemModel.cs" />
<Compile Include="Services\Jobs\JobQueues\IJobQueueToken.cs" />
<Compile Include="Services\Jobs\Noticeboards\IHeldDeviceItem.cs" />
<Compile Include="Services\Messaging\Email.cs" />
<Compile Include="Services\Messaging\EmailAttachment.cs" />
<Compile Include="Services\Users\Contact\UserContact.cs" />
<Compile Include="Services\Users\Contact\UserContactType.cs" />
<Compile Include="Services\Searching\DeviceSearchResultItem.cs" />
<Compile Include="Services\Searching\ISearchResultItem.cs" />
<Compile Include="Services\Searching\JobSearchResultItem.cs" />
<Compile Include="Services\Searching\UserSearchResultItem.cs" />
<Compile Include="Services\Users\UserFlags\UserFlagExportOptions.cs" />
<Compile Include="Services\Users\UserFlags\UserFlagExportRecord.cs" />
<Compile Include="UI\BaseUIModel.cs" />
<Compile Include="UI\Config\AuthorizationRole\ConfigAuthorizationRoleCreateModel.cs" />
<Compile Include="UI\Config\AuthorizationRole\ConfigAuthorizationRoleIndexModel.cs" />
@@ -158,6 +183,7 @@
<Compile Include="UI\Config\DeviceProfile\ConfigDeviceProfileIndexModel.cs" />
<Compile Include="UI\Config\DeviceProfile\ConfigDeviceProfileIndexModelItem.cs" />
<Compile Include="UI\Config\DeviceProfile\ConfigDeviceProfileShowModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateBulkGenerate.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateCreatePackageModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateCreateModel.cs" />
<Compile Include="UI\Config\DocumentTemplate\ConfigDocumentTemplateExpressionBrowserModel.cs" />
@@ -173,11 +199,17 @@
<Compile Include="UI\Config\JobQueue\ConfigJobQueueIndexModel.cs" />
<Compile Include="UI\Config\JobQueue\ConfigJobQueueShowModel.cs" />
<Compile Include="UI\Config\Logging\ConfigLoggingIndexModel.cs" />
<Compile Include="UI\Config\Shared\ConfigSharedDeviceGroupDocumentTemplateBulkGenerate.cs" />
<Compile Include="UI\Config\Shared\ConfigSharedTaskStatusModel.cs" />
<Compile Include="UI\Config\Organisation\ConfigOrganisationIndexModel.cs" />
<Compile Include="UI\Config\DeviceFlag\ConfigDeviceFlagCreateModel.cs" />
<Compile Include="UI\Config\DeviceFlag\ConfigDeviceFlagExportModel.cs" />
<Compile Include="UI\Config\DeviceFlag\ConfigDeviceFlagIndexModel.cs" />
<Compile Include="UI\Config\DeviceFlag\ConfigDeviceFlagShowModel.cs" />
<Compile Include="UI\Config\UserFlag\ConfigUserFlagCreateModel.cs" />
<Compile Include="UI\Config\UserFlag\ConfigUserFlagIndexModel.cs" />
<Compile Include="UI\Config\UserFlag\ConfigUserFlagShowModel.cs" />
<Compile Include="UI\Config\UserFlag\ConfigUserFlagExportModel.cs" />
<Compile Include="UI\Device\DeviceAddOfflineModel.cs" />
<Compile Include="UI\Device\DeviceExportModel.cs" />
<Compile Include="UI\Device\DeviceImportHeadersModel.cs" />
@@ -199,6 +231,11 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
@@ -0,0 +1,27 @@
using System;
namespace Disco.Models.Exporting
{
public class ExportFieldMetadata<T> where T : IExportRecord
{
public string Name { get; set; }
public string ColumnName { get; set; }
public Type ValueType { get; set; }
public Func<T, object> Accessor { get; set; }
public Func<object, string> CsvEncoder { get; set; }
public ExportFieldMetadata(string name, Type valueType, Func<T, object> accessor, Func<object, string> csvEncoder)
{
Name = name;
ValueType = valueType;
Accessor = accessor;
CsvEncoder = csvEncoder;
}
public ExportFieldMetadata(string name, string columnName, Type valueType, Func<T, object> accessor, Func<object, string> csvEncoder)
: this(name, valueType, accessor, csvEncoder)
{
ColumnName = columnName;
}
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace Disco.Models.Exporting
{
public enum ExportFormat
{
Csv,
Xlsx,
}
}
+12
View File
@@ -0,0 +1,12 @@
using System.IO;
namespace Disco.Models.Services.Exporting
{
public class ExportResult
{
public MemoryStream Result { get; set; }
public string Filename { get; set; }
public string MimeType { get; set; }
public int RecordCount { get; set; }
}
}
+12
View File
@@ -0,0 +1,12 @@
using Disco.Models.Exporting;
namespace Disco.Models.Services.Exporting
{
public interface IExportOptions
{
ExportFormat Format { get; }
string FilenamePrefix { get; }
string ExcelWorksheetName { get; }
string ExcelTableName { get; }
}
}
+6
View File
@@ -0,0 +1,6 @@
namespace Disco.Models.Exporting
{
public interface IExportRecord
{
}
}
+3 -3
View File
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.16320.1300")]
[assembly: AssemblyFileVersion("2.2.16320.1300")]
[assembly: AssemblyVersion("2.3.23161.0650")]
[assembly: AssemblyFileVersion("2.3.23161.0650")]
@@ -4,6 +4,7 @@
{
Device,
Job,
User
User,
DeviceBatch,
}
}
@@ -20,5 +20,9 @@ namespace Disco.Models.Repository
string DocumentTemplateId { get; set; }
AttachmentTypes AttachmentType { get; }
string HandlerId { get; set; }
string HandlerReferenceId { get; set; }
string HandlerData { get; set; }
}
}
+1
View File
@@ -51,6 +51,7 @@ namespace Disco.Models.Repository
[InverseProperty("DeviceSerialNumber")]
public virtual IList<Job> Jobs { get; set; }
public virtual IList<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
public override string ToString()
{
@@ -21,6 +21,12 @@ namespace Disco.Models.Repository
public string DocumentTemplateId { get; set; }
[StringLength(30)]
public string HandlerId { get; set; }
[StringLength(50)]
public string HandlerReferenceId { get; set; }
public string HandlerData { get; set; }
[NotMapped]
public object Reference { get { return DeviceSerialNumber; } }
@@ -50,6 +50,7 @@ namespace Disco.Models.Repository
[ForeignKey("DefaultDeviceModelId")]
public virtual DeviceModel DefaultDeviceModel { get; set; }
public virtual IList<DeviceBatchAttachment> DeviceBatchAttachments { get; set; }
public virtual IList<Device> Devices { get; set; }
public override string ToString()
@@ -0,0 +1,45 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class DeviceBatchAttachment : IAttachment
{
[Key]
public int Id { get; set; }
public int DeviceBatchId { get; set; }
[Required]
public string TechUserId { get; set; }
[StringLength(500), Required]
public string Filename { get; set; }
[Required, StringLength(500)]
public string MimeType { get; set; }
public DateTime Timestamp { get; set; }
[Required, StringLength(500)]
public string Comments { get; set; }
[NotMapped]
public string HandlerId { get => null; set { } }
[NotMapped]
public string HandlerReferenceId { get => null; set { } }
[NotMapped]
public string HandlerData { get => null; set { } }
[NotMapped]
public object Reference => DeviceBatchId;
[NotMapped]
public AttachmentTypes AttachmentType => AttachmentTypes.DeviceBatch;
[NotMapped]
public string DocumentTemplateId { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
[InverseProperty(nameof(Repository.DeviceBatch.DeviceBatchAttachments)), ForeignKey(nameof(DeviceBatchId))]
public virtual DeviceBatch DeviceBatch { get; set; }
[ForeignKey("TechUserId")]
public virtual User TechUser { get; set; }
}
}
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
@@ -16,6 +12,14 @@ namespace Disco.Models.Repository
public const string HardwareKeyACAdapter = "ACAdapter";
public const string HardwareKeyBattery = "Battery";
public const string HardwareKeyKeyboard = "Keyboard";
public const string HardwareKeyNetworkAdapters = "NetworkAdapters";
public const string HardwareKeyProcessors = "Processors";
public const string HardwareKeyPhysicalMemory = "PhysicalMemory";
public const string HardwareKeyDiskDrives = "DiskDrives";
public const string HardwareKeyBios = "Bios";
public const string HardwareKeyBaseBoard = "BaseBoard";
public const string HardwareKeyComputerSystem = "ComputerSystem";
public const string HardwareKeyBatteries = "Batteries";
[Column(Order = 0), Key]
public string DeviceSerialNumber { get; set; }
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Disco.Models.Repository
{
public class DeviceFlag
{
[Key]
public int Id { get; set; }
[Required, StringLength(100)]
public string Name { get; set; }
[StringLength(500), DataType(DataType.MultilineText)]
public string Description { get; set; }
[Required, StringLength(25)]
public string Icon { get; set; }
[Required, StringLength(10)]
public string IconColour { get; set; }
public string DevicesLinkedGroup { get; set; }
public string DeviceUsersLinkedGroup { get; set; }
[DataType(DataType.MultilineText)]
public string OnAssignmentExpression { get; set; }
[DataType(DataType.MultilineText)]
public string OnUnassignmentExpression { get; set; }
public virtual IList<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
public override string ToString()
{
return Name;
}
}
}
@@ -0,0 +1,44 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class DeviceFlagAssignment
{
[Key]
public int Id { get; set; }
[Required]
public int DeviceFlagId { get; set; }
[Required]
public string DeviceSerialNumber { get; set; }
[Required]
public DateTime AddedDate { get; set; }
[Required]
public string AddedUserId { get; set; }
public DateTime? RemovedDate { get; set; }
public string RemovedUserId { get; set; }
public string Comments { get; set; }
public string OnAssignmentExpressionResult { get; set; }
public string OnUnassignmentExpressionResult { get; set; }
[ForeignKey(nameof(DeviceFlagId)), InverseProperty("DeviceFlagAssignments")]
public virtual DeviceFlag DeviceFlag { get; set; }
[ForeignKey(nameof(DeviceSerialNumber)), InverseProperty("DeviceFlagAssignments")]
public virtual Device Device { get; set; }
[ForeignKey("AddedUserId")]
public virtual User AddedUser { get; set; }
[ForeignKey("RemovedUserId")]
public virtual User RemovedUser { get; set; }
public override string ToString()
{
return $"Device Flag Id: {DeviceFlagId}; Device Serial Number: {DeviceSerialNumber}; Added: {AddedDate:s}";
}
}
}
@@ -22,6 +22,7 @@ namespace Disco.Models.Repository
public string OnGenerateExpression { get; set; }
[DataType(DataType.MultilineText)]
public string OnImportAttachmentExpression { get; set; }
public string OnImportUserFlagRules { get; set; }
// Feature Request 2012-05-10 by G#: https://disco.uservoice.com/forums/159707-feedback/suggestions/2811092-document-template-option-flatten-form-on-generate
public bool FlattenForm { get; set; }
@@ -22,6 +22,12 @@ namespace Disco.Models.Repository
public string DocumentTemplateId { get; set; }
[StringLength(30)]
public string HandlerId { get; set; }
[StringLength(50)]
public string HandlerReferenceId { get; set; }
public string HandlerData { get; set; }
[NotMapped]
public object Reference { get { return JobId; } }
+20 -1
View File
@@ -71,21 +71,40 @@ namespace Disco.Models.Repository
return string.Format("{0} ({1})", this.DisplayName, this.UserId);
}
public void UpdateSelf(User u)
public bool UpdateSelf(User u)
{
var changed = false;
if (!this.UserId.Equals(u.UserId, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException("User Id's do not match", "u");
if (this.Surname != u.Surname)
{
this.Surname = u.Surname;
changed = true;
}
if (this.GivenName != u.GivenName)
{
this.GivenName = u.GivenName;
changed = true;
}
if (this.DisplayName != u.DisplayName)
{
this.DisplayName = u.DisplayName;
changed = true;
}
if (this.EmailAddress != u.EmailAddress)
{
this.EmailAddress = u.EmailAddress;
changed = true;
}
if (this.PhoneNumber != u.PhoneNumber)
{
this.PhoneNumber = u.PhoneNumber;
changed = true;
}
return changed;
}
}
}
@@ -21,6 +21,12 @@ namespace Disco.Models.Repository
public string DocumentTemplateId { get; set; }
[StringLength(30)]
public string HandlerId { get; set; }
[StringLength(50)]
public string HandlerReferenceId { get; set; }
public string HandlerData { get; set; }
[NotMapped]
public object Reference { get { return UserId; } }
@@ -0,0 +1,192 @@
using Disco.Models.Exporting;
using Disco.Models.Services.Exporting;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Disco.Models.Services.Devices.DeviceFlag
{
public class DeviceFlagExportOptions : IExportOptions
{
public ExportFormat Format { get; set; }
public string FilenamePrefix { get; } = "DiscoDeviceFlagExport";
public string ExcelWorksheetName { get; } = "DeviceFlagExport";
public string ExcelTableName { get; } = "DeviceFlags";
[Required]
public List<int> DeviceFlagIds { get; set; } = new List<int>();
[Display(Name = "Current Only")]
public bool CurrentOnly { get; set; }
// Device Flag
[Display(ShortName = "Device Flag", Name = "Identifier", Description = "The identifier of the device flag")]
public bool Id { get; set; }
[Display(ShortName = "Device Flag", Name = "Name", Description = "The name of the device flag")]
public bool Name { get; set; }
[Display(ShortName = "Device Flag", Name = "Description", Description = "The description of the device flag")]
public bool Description { get; set; }
[Display(ShortName = "Device Flag", Name = "Icon", Description = "The icon assigned to the device flag")]
public bool Icon { get; set; }
[Display(ShortName = "Device Flag", Name = "Icon Colour", Description = "The icon colour assigned to the device flag")]
public bool IconColour { get; set; }
[Display(ShortName = "Device Flag", Name = "Assignment Identifier", Description = "The identifier of the device flag assignment")]
public bool AssignmentId { get; set; }
[Display(ShortName = "Device Flag", Name = "Added Date", Description = "The date the device flag was assigned to the user")]
public bool AddedDate { get; set; }
[Display(ShortName = "Device Flag", Name = "Added User Identifier", Description = "The identifier of the user who assigned the device flag")]
public bool AddedUserId { get; set; }
[Display(ShortName = "Device Flag", Name = "Removed Date", Description = "The date the device flag was unassigned from the user")]
public bool RemovedDate { get; set; }
[Display(ShortName = "Device Flag", Name = "Removed User Identifier", Description = "The identifier of the user who unassigned the device flag")]
public bool RemovedUserId { get; set; }
[Display(ShortName = "Device Flag", Name = "Comments", Description = "The comments associated with the device flag assignment")]
public bool Comments { get; set; }
// Device
[Display(ShortName = "Device", Name = "Serial Number", Description = "The device serial number")]
public bool DeviceSerialNumber { get; set; }
[Display(ShortName = "Device", Name = "Asset Number", Description = "The device asset number")]
public bool DeviceAssetNumber { get; set; }
[Display(ShortName = "Device", Name = "Location", Description = "The device location")]
public bool DeviceLocation { get; set; }
[Display(ShortName = "Device", Name = "Computer Name", Description = "The device computer name")]
public bool DeviceComputerName { get; set; }
[Display(ShortName = "Device", Name = "Last Network Logon", Description = "The last recorded time the device access the network")]
public bool DeviceLastNetworkLogon { get; set; }
[Display(ShortName = "Device", Name = "Created Date", Description = "The date the device was created in Disco ICT")]
public bool DeviceCreatedDate { get; set; }
[Display(ShortName = "Device", Name = "First Enrolled Date", Description = "The date the device was first enrolled in Disco ICT")]
public bool DeviceFirstEnrolledDate { get; set; }
[Display(ShortName = "Device", Name = "Last Enrolled Date", Description = "The date the device was last enrolled in Disco ICT")]
public bool DeviceLastEnrolledDate { get; set; }
[Display(ShortName = "Device", Name = "Enrolment Trusted", Description = "The device is trusted to complete an unauthenticated enrolment")]
public bool DeviceAllowUnauthenticatedEnrol { get; set; }
[Display(ShortName = "Device", Name = "Decommissioned Date", Description = "The date the device was decommissioned in Disco ICT")]
public bool DeviceDecommissionedDate { get; set; }
[Display(ShortName = "Device", Name = "Decommissioned Reason", Description = "The reason the device was decommissioned")]
public bool DeviceDecommissionedReason { get; set; }
public bool HasDeviceOptions()
{
return DeviceSerialNumber ||
DeviceAssetNumber ||
DeviceLocation ||
DeviceComputerName ||
DeviceLastNetworkLogon ||
DeviceCreatedDate ||
DeviceFirstEnrolledDate ||
DeviceLastEnrolledDate ||
DeviceAllowUnauthenticatedEnrol ||
DeviceDecommissionedDate ||
DeviceDecommissionedReason;
}
// Model
[Display(ShortName = "Model", Name = "Identifier", Description = "The identifier of the device model associated with the device")]
public bool ModelId { get; set; }
[Display(ShortName = "Model", Name = "Description", Description = "The description of the device model associated with the device")]
public bool ModelDescription { get; set; }
[Display(ShortName = "Model", Name = "Manufacturer", Description = "The manufacturer of the device model associated with the device")]
public bool ModelManufacturer { get; set; }
[Display(ShortName = "Model", Name = "Model", Description = "The model of the device model associated with the device")]
public bool ModelModel { get; set; }
[Display(ShortName = "Model", Name = "Type", Description = "The type of device model associated with the device")]
public bool ModelType { get; set; }
public bool HasDeviceModelOptions()
{
return ModelId ||
ModelDescription ||
ModelManufacturer ||
ModelModel ||
ModelType;
}
// Batch
[Display(ShortName = "Batch", Name = "Identifier", Description = "The identifier of the device batch associated with the device")]
public bool BatchId { get; set; }
[Display(ShortName = "Batch", Name = "Name", Description = "The name of the device batch associated with the device")]
public bool BatchName { get; set; }
[Display(ShortName = "Batch", Name = "Purchase Date", Description = "The purchase date of the device batch associated with the device")]
public bool BatchPurchaseDate { get; set; }
[Display(ShortName = "Batch", Name = "Supplier", Description = "The supplier of the device batch associated with the device")]
public bool BatchSupplier { get; set; }
[Display(ShortName = "Batch", Name = "Unit Cost", Description = "The unit cost of the device batch associated with the device")]
public bool BatchUnitCost { get; set; }
[Display(ShortName = "Batch", Name = "Warranty Valid Until Date", Description = "The warranty valid until date of the device batch associated with the device")]
public bool BatchWarrantyValidUntilDate { get; set; }
[Display(ShortName = "Batch", Name = "Insured Date", Description = "The insured date of the device batch associated with the device")]
public bool BatchInsuredDate { get; set; }
[Display(ShortName = "Batch", Name = "Insurance Supplier", Description = "The insurance supplier of the device batch associated with the device")]
public bool BatchInsuranceSupplier { get; set; }
[Display(ShortName = "Batch", Name = "Insured Until Date", Description = "The insured until date of the device batch associated with the device")]
public bool BatchInsuredUntilDate { get; set; }
public bool HasDeviceBatchOptions()
{
return BatchId ||
BatchName ||
BatchPurchaseDate ||
BatchSupplier ||
BatchUnitCost ||
BatchWarrantyValidUntilDate ||
BatchInsuredDate ||
BatchInsuranceSupplier ||
BatchInsuredUntilDate;
}
// Profile
[Display(ShortName = "Profile", Name = "Identifier", Description = "The identifier of the device profile associated with the device")]
public bool ProfileId { get; set; }
[Display(ShortName = "Profile", Name = "Name", Description = "The name of the device profile associated with the device")]
public bool ProfileName { get; set; }
[Display(ShortName = "Profile", Name = "Short Name", Description = "The short name of the device profile associated with the device")]
public bool ProfileShortName { get; set; }
public bool HasDeviceProfileOptions()
{
return ProfileId ||
ProfileName ||
ProfileShortName;
}
// Assigned User
[Display(ShortName = "Assigned User", Name = "Identifier", Description = "The identifier of the user assigned to the device flag")]
public bool AssignedUserId { get; set; }
[Display(ShortName = "Assigned User", Name = "Display Name", Description = "The display name of the user assigned to the device flag")]
public bool AssignedUserDisplayName { get; set; }
[Display(ShortName = "Assigned User", Name = "Surname", Description = "The surname of the user assigned to the device flag")]
public bool AssignedUserSurname { get; set; }
[Display(ShortName = "Assigned User", Name = "Given Name", Description = "The given name of the user assigned to the device flag")]
public bool AssignedUserGivenName { get; set; }
[Display(ShortName = "Assigned User", Name = "Phone Number", Description = "The phone number of the user assigned to the device flag")]
public bool AssignedUserPhoneNumber { get; set; }
[Display(ShortName = "Assigned User", Name = "Email Address", Description = "The email address of the user assigned to the device flag")]
public bool AssignedUserEmailAddress { get; set; }
[Display(ShortName = "Assigned User", Name = "Custom Details", Description = "The custom details provided by plugins for the user assigned to the device flag")]
public bool AssignedUserDetailCustom { get; set; }
public bool HasAssignedUserOptions()
{
return AssignedUserId ||
AssignedUserDisplayName ||
AssignedUserSurname ||
AssignedUserGivenName ||
AssignedUserPhoneNumber ||
AssignedUserEmailAddress;
}
public static DeviceFlagExportOptions DefaultOptions()
{
return new DeviceFlagExportOptions()
{
Format = ExportFormat.Xlsx,
CurrentOnly = true,
Name = true,
AddedDate = true,
DeviceSerialNumber = true,
ModelDescription = true,
ProfileName = true,
AssignedUserId = true,
AssignedUserDisplayName = true,
Comments = true,
};
}
}
}
@@ -0,0 +1,12 @@
using Disco.Models.Exporting;
using Disco.Models.Repository;
using System.Collections.Generic;
namespace Disco.Models.Services.Devices.DeviceFlag
{
public class DeviceFlagExportRecord : IExportRecord
{
public DeviceFlagAssignment Assignment { get; set; }
public Dictionary<string, string> AssignedUserCustomDetails { get; set; }
}
}
@@ -1,21 +1,18 @@
using System;
using System.Collections.Generic;
using Disco.Models.Exporting;
using Disco.Models.Services.Exporting;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Exporting
{
public class DeviceExportOptions
public class DeviceExportOptions : IExportOptions
{
public DeviceExportTypes ExportType { get; set; }
public int? ExportTypeTargetId { get; set; }
/// <summary>
/// Adds '=' to the beginning of the string to stop Excel removing the leading zeros
/// </summary>
public bool ExcelCsvFormat { get; set; }
public ExportFormat Format { get; set; }
public string FilenamePrefix { get; } = "DiscoDeviceExport";
public string ExcelWorksheetName { get; } = "DeviceExport";
public string ExcelTableName { get; } = "Devices";
// Device
[Display(ShortName = "Device", Name = "Serial Number", Description = "The device serial number")]
@@ -28,31 +25,19 @@ namespace Disco.Models.Services.Devices.Exporting
public bool DeviceComputerName { get; set; }
[Display(ShortName = "Device", Name = "Last Network Logon", Description = "The last recorded time the device access the network")]
public bool DeviceLastNetworkLogon { get; set; }
[Display(ShortName = "Device", Name = "Created Date", Description = "The date the device was created in Disco")]
[Display(ShortName = "Device", Name = "Created Date", Description = "The date the device was created in Disco ICT")]
public bool DeviceCreatedDate { get; set; }
[Display(ShortName = "Device", Name = "First Enrolled Date", Description = "The date the device was first enrolled in Disco")]
[Display(ShortName = "Device", Name = "First Enrolled Date", Description = "The date the device was first enrolled in Disco ICT")]
public bool DeviceFirstEnrolledDate { get; set; }
[Display(ShortName = "Device", Name = "Last Enrolled Date", Description = "The date the device was last enrolled in Disco")]
[Display(ShortName = "Device", Name = "Last Enrolled Date", Description = "The date the device was last enrolled in Disco ICT")]
public bool DeviceLastEnrolledDate { get; set; }
[Display(ShortName = "Device", Name = "Enrolment Trusted", Description = "The device is trusted to complete an unauthenticated enrolment")]
public bool DeviceAllowUnauthenticatedEnrol { get; set; }
[Display(ShortName = "Device", Name = "Decommissioned Date", Description = "The date the device was decommissioned in Disco")]
[Display(ShortName = "Device", Name = "Decommissioned Date", Description = "The date the device was decommissioned in Disco ICT")]
public bool DeviceDecommissionedDate { get; set; }
[Display(ShortName = "Device", Name = "Decommissioned Reason", Description = "The reason the device was decommissioned")]
public bool DeviceDecommissionedReason { get; set; }
// Details
[Display(ShortName = "Details", Name = "LAN MAC Address", Description = "The LAN MAC Address associated with the device")]
public bool DetailLanMacAddress { get; set; }
[Display(ShortName = "Details", Name = "Wireless LAN MAC Address", Description = "The Wireless LAN MAC Address associated with the device")]
public bool DetailWLanMacAddress { get; set; }
[Display(ShortName = "Details", Name = "AC Adapter", Description = "The AC Adapter associated with the device")]
public bool DetailACAdapter { get; set; }
[Display(ShortName = "Details", Name = "Battery", Description = "The Battery associated with the device")]
public bool DetailBattery { get; set; }
[Display(ShortName = "Details", Name = "Keyboard", Description = "The Keyboard associated with the device")]
public bool DetailKeyboard { get; set; }
// Model
[Display(ShortName = "Model", Name = "Identifier", Description = "The identifier of the device model associated with the device")]
public bool ModelId { get; set; }
@@ -108,6 +93,8 @@ namespace Disco.Models.Services.Devices.Exporting
public bool AssignedUserPhoneNumber { get; set; }
[Display(ShortName = "Assigned User", Name = "Email Address", Description = "The email address of the user assigned to the device")]
public bool AssignedUserEmailAddress { get; set; }
[Display(ShortName = "Assigned User", Name = "Custom Details", Description = "The custom details provided by plugins for the user assigned to the device")]
public bool AssignedUserDetailCustom { get; set; }
// Jobs
[Display(ShortName = "Jobs", Name = "Count", Description = "The total number of jobs associated with the device")]
@@ -120,22 +107,41 @@ namespace Disco.Models.Services.Devices.Exporting
public bool AttachmentsCount { get; set; }
// Certificates
[Display(ShortName = "Certificates", Name = "Name", Description = "The name of the most recently assigned active certificate associated with the device")]
public bool CertificateName { get; set; }
[Display(ShortName = "Certificates", Name = "Allocated Date", Description = "The allocated date of the most recently assigned active certificate associated with the device")]
public bool CertificateAllocatedDate { get; set; }
[Display(ShortName = "Certificates", Name = "Expiration Date", Description = "The expiration date of the most recently assigned active certificate associated with the device")]
public bool CertificateExpirationDate { get; set; }
[Display(ShortName = "Certificates", Name = "Provider Id", Description = "The provider identifier of the most recently assigned active certificate associated with the device")]
public bool CertificateProviderId { get; set; }
[Display(ShortName = "Certificates", Name = "Certificates", Description = "The assigned active certificates associated with the device")]
public bool Certificates { get; set; }
// Details
[Display(ShortName = "Details", Name = "BIOS", Description = "The BIOS associated with the device")]
public bool DetailBios { get; set; }
[Display(ShortName = "Details", Name = "Base Board", Description = "The Base Board associated with the device")]
public bool DetailBaseBoard { get; set; }
[Display(ShortName = "Details", Name = "System", Description = "The System information associated with the device")]
public bool DetailComputerSystem { get; set; }
[Display(ShortName = "Details", Name = "Processors", Description = "The CPU Processors associated with the device")]
public bool DetailProcessors { get; set; }
[Display(ShortName = "Details", Name = "Memory", Description = "The Memory/RAM associated with the device")]
public bool DetailMemory { get; set; }
[Display(ShortName = "Details", Name = "Disk Drives", Description = "The Disk Drives associated with the device")]
public bool DetailDiskDrives { get; set; }
[Display(ShortName = "Details", Name = "LAN Adapters", Description = "The LAN Adapters associated with the device")]
public bool DetailLanAdapters { get; set; }
[Display(ShortName = "Details", Name = "Wireless LAN Adapters", Description = "The Wireless LAN Adapters associated with the device")]
public bool DetailWLanAdapters { get; set; }
[Display(ShortName = "Details", Name = "AC Adapter", Description = "The AC Adapter associated with the device")]
public bool DetailACAdapter { get; set; }
[Display(ShortName = "Details", Name = "Battery", Description = "The manually entered battery associated with the device")]
public bool DetailBatteries { get; set; }
[Display(ShortName = "Details", Name = "Batteries", Description = "The reported batteries associated with the device")]
public bool DetailBattery { get; set; }
[Display(ShortName = "Details", Name = "Keyboard", Description = "The Keyboard associated with the device")]
public bool DetailKeyboard { get; set; }
public static DeviceExportOptions DefaultOptions()
{
return new DeviceExportOptions()
{
ExportType = DeviceExportTypes.All,
ExcelCsvFormat = true,
Format = ExportFormat.Xlsx,
DeviceSerialNumber = true,
ModelId = true,
ProfileId = true,
@@ -1,16 +1,28 @@
using Disco.Models.Repository;
using Disco.Models.ClientServices.EnrolmentInformation;
using Disco.Models.Exporting;
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
namespace Disco.Models.Services.Devices.Exporting
{
public class DeviceExportRecord
public class DeviceExportRecord : IExportRecord
{
public Device Device { get; set; }
// Details
public IEnumerable<DeviceDetail> DeviceDetails { get; set; }
public IList<DeviceDetail> DeviceDetails { get; set; }
public List<Bios> DeviceDetailBios { get; set; }
public List<BaseBoard> DeviceDetailBaseBoard { get; set; }
public List<ComputerSystem> DeviceDetailComputerSystem { get; set; }
public List<Processor> DeviceDetailProcessors { get; set; }
public List<PhysicalMemory> DeviceDetailPhysicalMemory { get; set; }
public List<DiskDrive> DeviceDetailDiskDrives { get; set; }
public List<NetworkAdapter> DeviceDetailNetworkAdapters { get; set; }
public List<string> DeviceDetailLanMacAddresses { get; set; }
public List<string> DeviceDetailWlanMacAddresses { get; set; }
public List<Battery> DeviceDetailBatteries { get; set; }
// Model
public int? ModelId { get; set; }
public string ModelDescription { get; set; }
@@ -37,6 +49,8 @@ namespace Disco.Models.Services.Devices.Exporting
// User
public DeviceUserAssignment DeviceUserAssignment { get; set; }
public User AssignedUser { get; set; }
public IList<UserDetail> AssignedUserDetails { get; set; }
public Dictionary<string, string> AssignedUserCustomDetails { get; set; }
// Jobs
public int JobsTotalCount { get; set; }
@@ -46,6 +60,6 @@ namespace Disco.Models.Services.Devices.Exporting
public int AttachmentsCount { get; set; }
// Certificates
public DeviceCertificate DeviceCertificate { get; set; }
public IEnumerable<DeviceCertificate> DeviceCertificates { get; set; }
}
}
@@ -1,10 +0,0 @@
using System.IO;
namespace Disco.Models.Services.Devices.Exporting
{
public class DeviceExportResult
{
public MemoryStream CsvResult { get; set; }
public int RecordCount { get; set; }
}
}
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Exporting
namespace Disco.Models.Services.Devices.Exporting
{
public enum DeviceExportTypes
{
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace Disco.Models.Services.Devices.Importing
{
@@ -11,13 +6,15 @@ namespace Disco.Models.Services.Devices.Importing
{
[Required, Display(Name = "Device Serial Number", Description = "The device serial number")]
DeviceSerialNumber,
[Display(Name = "Device Computer Name", Description = "The device computer name")]
DeviceComputerName,
[Display(Name = "Device Asset Number", Description = "The device asset number")]
DeviceAssetNumber,
[Display(Name = "Device Location", Description = "The device location")]
DeviceLocation,
[Display(Name = "Device Enrolment Trusted", Description = "The device is trusted to complete an unauthenticated enrolment")]
DeviceAllowUnauthenticatedEnrol,
[Display(Name = "Device Decommissioned Date", Description = "The date the device was decommissioned in Disco")]
[Display(Name = "Device Decommissioned Date", Description = "The date the device was decommissioned in Disco ICT")]
DeviceDecommissionedDate,
[Display(Name = "Device Decommissioned Reason", Description = "The reason the device was decommissioned")]
DeviceDecommissionedReason,
@@ -0,0 +1,14 @@
using System;
namespace Disco.Models.Services.Devices.Importing
{
public interface IDeviceImportColumn
{
int Index { get; }
string Name { get; }
DeviceImportFieldTypes Type { get; }
Type Handler { get; }
IDeviceImportField GetHandlerInstance();
}
}
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Importing
{
@@ -10,11 +7,19 @@ namespace Disco.Models.Services.Devices.Importing
{
string SessionId { get; }
string Filename { get; }
List<Tuple<string, DeviceImportFieldTypes>> Header { get; }
List<Tuple<string, DeviceImportFieldTypes, Func<string[], string>, Type>> ParsedHeaders { get; }
List<string[]> RawData { get; }
string DatasetName { get; }
int ColumnCount { get; }
IEnumerable<IDeviceImportColumn> Columns { get; }
IDeviceImportColumn GetColumn(int Index);
void SetColumnType(int Index, DeviceImportFieldTypes Type);
int? GetColumnByType(DeviceImportFieldTypes FieldType);
List<IDeviceImportRecord> Records { get; }
int AffectedRecords { get; }
int RecordCount { get; }
IDeviceImportDataReader GetDataReader();
IEnumerable<KeyValuePair<DeviceImportFieldTypes, Type>> GetFieldHandlers();
List<IDeviceImportRecord> Records { get; set; }
int AffectedRecords { get; set; }
}
}
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Importing
{
public interface IDeviceImportDataReader : IDisposable
{
void Reset();
bool Read();
int Index { get; }
int GetRowNumber(int Index);
string GetString(int ColumnIndex);
IEnumerable<string> GetStrings(int ColumnIndex);
bool TryGetNullableInt(int ColumnIndex, out int? value);
bool TryGetNullableBool(int ColumnIndex, out bool? value);
bool TryGetNullableDateTime(int ColumnIndex, out DateTime? value);
bool TestAllNotEmpty(int ColumnIndex);
bool TestAllNullableInt(int ColumnIndex);
bool TestAllInt(int ColumnIndex);
bool TestAllNullableBool(int ColumnIndex);
bool TestAllNullableDateTime(int ColumnIndex);
}
}
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
namespace Disco.Models.Services.Devices.Importing
{
@@ -9,6 +9,7 @@ namespace Disco.Models.Services.Devices.Importing
{
public interface IDeviceImportRecord
{
int Index { get; }
string DeviceSerialNumber { get; }
IEnumerable<IDeviceImportField> Fields { get; }
@@ -0,0 +1,28 @@
using System.Collections.Generic;
namespace Disco.Models.Services.Documents
{
public class DocumentField
{
public string Name { get; }
public string Value { get; }
public int Ordinal { get; }
public DocumentFieldType Type { get; }
public bool IsRequired { get; }
public bool IsReadOnly { get; }
public List<string> FixedValues { get; }
public DocumentField(string name, string value, int ordinal, DocumentFieldType type, bool isRequired, bool isReadOnly, List<string> fixedValues)
{
Name = name;
Value = value;
Ordinal = ordinal;
Type = type;
IsRequired = isRequired;
IsReadOnly = isReadOnly;
FixedValues = fixedValues;
}
}
}
@@ -0,0 +1,14 @@
namespace Disco.Models.Services.Documents
{
public enum DocumentFieldType
{
None = 0,
PushButton = 1,
Checkbox = 2,
RadioButton = 3,
Text = 4,
List = 5,
Combo = 6,
Signature = 7,
}
}
@@ -0,0 +1,20 @@
using Disco.Models.Repository;
using Newtonsoft.Json;
using System;
using System.ComponentModel.DataAnnotations;
namespace Disco.Models.Services.Documents
{
public class OnImportUserFlagRule
{
public Guid Id { get; set; }
public int FlagId { get; set; }
[StringLength(50)]
public string UserId { get; set; }
public bool AddFlag { get; set; }
public string Comments { get; set; }
[JsonIgnore]
public UserFlag UserFlag { get; set; }
}
}
@@ -1,12 +1,13 @@
using System.IO;
namespace Disco.Models.BI.Expressions
namespace Disco.Models.Services.Expressions.Extensions
{
public interface IImageExpressionResult
{
Stream GetImage(int Width, int Height);
MemoryStream GetImage(int width, int height);
MemoryStream GetImage(out int width, out int height);
byte Quality { get; set; }
bool LosslessFormat { get; set; }
ImageExpressionFormat Format { get; set; }
bool ShowField { get; set; }
string BackgroundColour { get; set; }
bool BackgroundPreferTransparent { get; set; }
@@ -0,0 +1,9 @@
namespace Disco.Models.Services.Expressions.Extensions
{
public enum ImageExpressionFormat
{
Jpeg,
Png,
CcittG4,
}
}
+38
View File
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Disco.Models.Services.Messaging
{
public class Email
{
public string From { get; set; }
public string ReplyTo { get; set; }
public List<string> To { get; } = new List<string>();
public List<string> CC { get; } = new List<string>();
public List<string> BCC { get; } = new List<string>();
public string Subject { get; set; }
public bool IsBodyHtml { get; set; }
public string Body { get; set; }
public List<EmailAttachment> Attachments { get; } = new List<EmailAttachment>();
public Email()
{
}
public Email(string to, string subject, string body)
: this()
{
To.Add(to);
Subject = subject;
Body = body;
}
public static IEnumerable<string> ParseEmailAddresses(string emailAddresses)
{
return emailAddresses.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim());
}
}
}
@@ -0,0 +1,8 @@
namespace Disco.Models.Services.Messaging
{
public class EmailAttachment
{
public string Name { get; set; }
public byte[] Data { get; set; }
}
}
@@ -1,4 +1,5 @@
using System;
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -40,10 +41,11 @@ namespace Disco.Models.Services.Searching
public string AssignedUserId { get; set; }
public string ComputerName { get; set; }
public string DeviceModelDescription { get; set; }
public string DeviceProfileDescription { get; set; }
public string DeviceProfileName { get; set; }
public string DeviceBatchName { get; set; }
public int JobCount { get; set; }
public DateTime? DecommissionedDate { get; set; }
public IList<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
private string[] BuildScoreValues()
{
@@ -0,0 +1,161 @@
using Disco.Models.Repository;
using System;
using System.Linq;
using System.Text.RegularExpressions;
namespace Disco.Models.Services.Users.Contact
{
public abstract class UserContact
{
public User User { get; }
public UserContactType ContactType { get; }
public string Source { get; }
public string Name { get; }
public abstract string Value { get; }
public UserContact(User user, UserContactType contactType, string source, string name)
{
User = user;
ContactType = contactType;
Source = source;
Name = name;
}
protected static bool TryParse<T>(User user, string source, Regex validator, string value, Func<User, string, string, string, T> generator, out T instance) where T : UserContact
{
if (string.IsNullOrWhiteSpace(value))
{
instance = null;
return false;
}
var match = validator.Match(value);
if (!match.Success)
{
instance = null;
return false;
}
var result = match.Value;
var name = default(string);
if (match.Index > 0)
{
name = value.Substring(0, match.Index).Trim();
if (name.Length > 0)
{
switch (name.Last())
{
case '<':
case '[':
case '(':
case '{':
case '-':
name = name.Substring(0, name.Length - 1).Trim();
break;
}
}
if (name.Length == 0)
name = default;
}
instance = generator(user, source, name, result);
return true;
}
public override string ToString()
{
if (!string.IsNullOrWhiteSpace(Name))
{
return $"{Name} <{Value}>";
}
else
{
return Value;
}
}
}
public sealed class UserContactEmail : UserContact
{
private static Regex validator = new Regex(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public string EmailAddress { get; }
public override string Value => EmailAddress;
public UserContactEmail(User user, string source, string name, string emailAddress)
: base(user, UserContactType.Email, source, name)
{
if (string.IsNullOrWhiteSpace(emailAddress))
throw new ArgumentNullException(nameof(emailAddress));
EmailAddress = emailAddress;
}
public static bool TryParse(User user, string source, string value, out UserContactEmail contact) =>
TryParse(user, source, validator, value,
(u, s, name, emailAddress) => new UserContactEmail(u, s, name, emailAddress),
out contact);
}
public sealed class UserContactAustralianPhone : UserContact
{
private static Regex validator = new Regex(@"(?:\+?61\s*[0-9][ \-\.]*?|0[0-9][ \-\.]*?|[(\[]\s*0[0-9]\s*[)\]])\s*(?:[0-9][ \-\.]*?){8}(?=\s*[>\]})\-]?\s*$)", RegexOptions.Compiled);
public string PhoneNumber { get; }
public override string Value => PhoneNumber;
public UserContactAustralianPhone(User user, string source, string name, string phoneNumber)
: base(user, UserContactType.Phone, source, name)
{
if (string.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
PhoneNumber = phoneNumber;
}
public static bool TryParse(User user, string source, string value, out UserContactAustralianPhone contact) =>
TryParse(user, source, validator, value,
(u, s, name, phoneNumber) => new UserContactAustralianPhone(u, s, name, phoneNumber),
out contact);
public override string ToString()
{
if (!string.IsNullOrWhiteSpace(Name))
return $"{Name} <{PhoneNumber}>";
else
return PhoneNumber;
}
}
public sealed class UserContactAustralianMobile : UserContact
{
private static Regex validator = new Regex(@"(?:\+?61\s*4[ \-\.]*?|04[ \-\.]*?|[(\[]\s*04\s*[)\]])\s*(?:[0-9][ \-\.]*?){8}(?=\s*[>\]})\-]?\s*$)", RegexOptions.Compiled);
public string PhoneNumber { get; }
public override string Value => PhoneNumber;
public UserContactAustralianMobile(User user, string source, string name, string phoneNumber)
: base(user, UserContactType.MobilePhone, source, name)
{
if (string.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
PhoneNumber = phoneNumber;
}
public static bool TryParse(User user, string source, string value, out UserContactAustralianPhone contact) =>
TryParse(user, source, validator, value,
(u, s, name, phoneNumber) => new UserContactAustralianPhone(u, s, name, phoneNumber),
out contact);
public override string ToString()
{
if (!string.IsNullOrWhiteSpace(Name))
return $"{Name} <{PhoneNumber}>";
else
return PhoneNumber;
}
}
}
@@ -0,0 +1,14 @@
using System;
namespace Disco.Models.Services.Users.Contact
{
[Flags]
public enum UserContactType
{
Email = 1,
MobilePhone,
Phone,
AddressMail,
AddressHome,
}
}
@@ -0,0 +1,76 @@
using Disco.Models.Exporting;
using Disco.Models.Services.Exporting;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Disco.Models.Services.Users.UserFlags
{
public class UserFlagExportOptions : IExportOptions
{
public ExportFormat Format { get; set; }
public string FilenamePrefix { get; } = "DiscoUserFlagExport";
public string ExcelWorksheetName { get; } = "UserFlagExport";
public string ExcelTableName { get; } = "UserFlags";
[Required]
public List<int> UserFlagIds { get; set; } = new List<int>();
[Display(Name = "Current Only")]
public bool CurrentOnly { get; set; }
// User Flag
[Display(ShortName = "User Flag", Name = "Identifier", Description = "The identifier of the user flag")]
public bool Id { get; set; }
[Display(ShortName = "User Flag", Name = "Name", Description = "The name of the user flag")]
public bool Name { get; set; }
[Display(ShortName = "User Flag", Name = "Description", Description = "The description of the user flag")]
public bool Description { get; set; }
[Display(ShortName = "User Flag", Name = "Icon", Description = "The icon assigned to the user flag")]
public bool Icon { get; set; }
[Display(ShortName = "User Flag", Name = "Icon Colour", Description = "The icon colour assigned to the user flag")]
public bool IconColour { get; set; }
[Display(ShortName = "User Flag", Name = "Assignment Identifier", Description = "The identifier of the user flag assignment")]
public bool AssignmentId { get; set; }
[Display(ShortName = "User Flag", Name = "Added Date", Description = "The date the user flag was assigned to the user")]
public bool AddedDate { get; set; }
[Display(ShortName = "User Flag", Name = "Added User Identifier", Description = "The identifier of the user who assigned the user flag")]
public bool AddedUserId { get; set; }
[Display(ShortName = "User Flag", Name = "Removed Date", Description = "The date the user flag was unassigned from the user")]
public bool RemovedDate { get; set; }
[Display(ShortName = "User Flag", Name = "Removed User Identifier", Description = "The identifier of the user who unassigned the user flag")]
public bool RemovedUserId { get; set; }
[Display(ShortName = "User Flag", Name = "Comments", Description = "The comments associated with the user flag assignment")]
public bool Comments { get; set; }
// User
[Display(ShortName = "User", Name = "Identifier", Description = "The identifier of the user assigned to the user flag")]
public bool UserId { get; set; }
[Display(ShortName = "User", Name = "Display Name", Description = "The display name of the user assigned to the user flag")]
public bool UserDisplayName { get; set; }
[Display(ShortName = "User", Name = "Surname", Description = "The surname of the user assigned to the user flag")]
public bool UserSurname { get; set; }
[Display(ShortName = "User", Name = "Given Name", Description = "The given name of the user assigned to the user flag")]
public bool UserGivenName { get; set; }
[Display(ShortName = "User", Name = "Phone Number", Description = "The phone number of the user assigned to the user flag")]
public bool UserPhoneNumber { get; set; }
[Display(ShortName = "User", Name = "Email Address", Description = "The email address of the user assigned to the user flag")]
public bool UserEmailAddress { get; set; }
[Display(ShortName = "User", Name = "Custom Details", Description = "The custom details provided by plugins for the user assigned to the user flag")]
public bool UserDetailCustom { get; set; }
public static UserFlagExportOptions DefaultOptions()
{
return new UserFlagExportOptions()
{
Format = ExportFormat.Xlsx,
CurrentOnly = true,
Name = true,
AddedDate = true,
UserId = true,
UserDisplayName = true,
Comments = true,
};
}
}
}

Some files were not shown because too many files have changed in this diff Show More