103 Commits

Author SHA1 Message Date
dependabot[bot] 83bd81b127 build(deps): bump jQuery.Validation from 1.12.0 to 1.19.4 in /Disco.Web
Bumps jQuery.Validation from 1.12.0 to 1.19.4.

---
updated-dependencies:
- dependency-name: jQuery.Validation
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-30 19:44:12 +00: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
563 changed files with 66062 additions and 14908 deletions
@@ -8,8 +8,9 @@ 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.Data.Entity;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -17,28 +18,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 +77,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);
+49 -21
View File
@@ -7,12 +7,12 @@ 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);
@@ -288,8 +315,9 @@ 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 = iTextSharp.text.Image.GetInstance(imageResult.GetImage((int)(pdfFieldPosition.position.Width * 1.6), (int)(pdfFieldPosition.position.Height * 1.6)));
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)
+1 -1
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco</RootNamespace>
<AssemblyName>Disco.BI</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+2 -2
View File
@@ -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.2.16326.0500")]
[assembly: AssemblyFileVersion("2.2.16326.0500")]
+3 -3
View File
@@ -30,7 +30,7 @@
</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" />
<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" />
@@ -46,11 +46,11 @@
</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" />
<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" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
+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)
{
+463 -50
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
{
@@ -81,11 +335,11 @@ namespace Disco.Client.Interop
}
}
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
{
@@ -121,7 +398,7 @@ namespace Disco.Client.Interop
}
}
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
@@ -154,48 +431,84 @@ namespace Disco.Client.Interop
}
}
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 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
{
@@ -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,
}
}
}
+2 -2
View File
@@ -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.2.16326.0500")]
[assembly: AssemblyFileVersion("2.2.16326.0500")]
+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>
+5 -5
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)
{
@@ -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>
@@ -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)
@@ -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.2.16326.0500")]
[assembly: AssemblyFileVersion("2.2.16326.0500")]
@@ -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
{
+29 -3
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco.Data</RootNamespace>
<AssemblyName>Disco.Data</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.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,18 @@
<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\Configuration.cs" />
<Compile Include="Migrations\DiscoDataMigrator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -235,6 +247,15 @@
<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="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -246,6 +267,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
+2 -2
View File
@@ -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.2.16326.0500")]
[assembly: AssemblyFileVersion("2.2.16326.0500")]
@@ -22,6 +22,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,6 +35,7 @@ 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; }
+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" />
@@ -5,6 +5,7 @@ namespace Disco.Models.BI.Expressions
public interface IImageExpressionResult
{
Stream GetImage(int Width, int Height);
Stream GetImage();
byte Quality { get; set; }
bool LosslessFormat { get; set; }
bool ShowField { get; set; }
@@ -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; }
}
}
+25 -3
View File
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco.Models</RootNamespace>
<AssemblyName>Disco.Models</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.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,10 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BI\Config\OrganisationAddress.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 +64,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\Exporting\DeviceExportFieldMetadata.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="Services\Jobs\LocationModes.cs" />
<Compile Include="ClientServices\EnrolmentInformation\Certificate.cs" />
<Compile Include="ClientServices\Register.cs" />
@@ -135,6 +146,10 @@
<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" />
@@ -158,6 +173,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,6 +189,7 @@
<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\UserFlag\ConfigUserFlagCreateModel.cs" />
@@ -199,6 +216,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">
+2 -2
View File
@@ -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.2.16326.0500")]
[assembly: AssemblyFileVersion("2.2.16326.0500")]
@@ -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; }
}
}
@@ -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; }
@@ -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,27 @@
using System;
namespace Disco.Models.Services.Devices.Exporting
{
public class DeviceExportFieldMetadata
{
public string Name { get; set; }
public string ColumnName { get; set; }
public Type ValueType { get; set; }
public Func<DeviceExportRecord, object> Accessor { get; set; }
public Func<object, string> CsvEncoder { get; set; }
public DeviceExportFieldMetadata(string name, Type valueType, Func<DeviceExportRecord, object> accessor, Func<object, string> csvEncoder)
{
Name = name;
ValueType = valueType;
Accessor = accessor;
CsvEncoder = csvEncoder;
}
public DeviceExportFieldMetadata(string name, string columnName, Type valueType, Func<DeviceExportRecord, object> accessor, Func<object, string> csvEncoder)
: this(name, valueType, accessor, csvEncoder)
{
ColumnName = columnName;
}
}
}
@@ -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.Exporting
{
@@ -12,10 +7,7 @@ namespace Disco.Models.Services.Devices.Exporting
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 bool ExcelFormat { get; set; }
// Device
[Display(ShortName = "Device", Name = "Serial Number", Description = "The device serial number")]
@@ -41,18 +33,6 @@ namespace Disco.Models.Services.Devices.Exporting
[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 +88,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 +102,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,
ExcelFormat = true,
DeviceSerialNumber = true,
ModelId = true,
ProfileId = true,
@@ -1,4 +1,5 @@
using Disco.Models.Repository;
using Disco.Models.ClientServices.EnrolmentInformation;
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
@@ -9,8 +10,18 @@ namespace Disco.Models.Services.Devices.Exporting
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 +48,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 +59,6 @@ namespace Disco.Models.Services.Devices.Exporting
public int AttachmentsCount { get; set; }
// Certificates
public DeviceCertificate DeviceCertificate { get; set; }
public IEnumerable<DeviceCertificate> DeviceCertificates { get; set; }
}
}
@@ -4,7 +4,7 @@ namespace Disco.Models.Services.Devices.Exporting
{
public class DeviceExportResult
{
public MemoryStream CsvResult { get; set; }
public MemoryStream Result { get; set; }
public int RecordCount { get; set; }
}
}
@@ -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,6 +6,8 @@ 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")]
@@ -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; }
}
}
+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; }
}
}
@@ -40,7 +40,7 @@ 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; }
@@ -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,
}
}
@@ -1,18 +1,15 @@
using System;
using Disco.Models.UI.Config.Shared;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.Config.DeviceBatch
{
public interface ConfigDeviceBatchShowModel : BaseUIModel
public interface ConfigDeviceBatchShowModel : BaseUIModel, ConfigSharedDeviceGroupDocumentTemplateBulkGenerate
{
Disco.Models.Repository.DeviceBatch DeviceBatch { get; set; }
Repository.DeviceBatch DeviceBatch { get; set; }
Disco.Models.Repository.DeviceModel DefaultDeviceModel { get; set; }
Repository.DeviceModel DefaultDeviceModel { get; set; }
List<Disco.Models.Repository.DeviceModel> DeviceModels { get; set; }
List<Repository.DeviceModel> DeviceModels { get; set; }
List<ConfigDeviceBatchShowModelMembership> DeviceModelMembers { get; set; }
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.Models.UI.Config.Shared;
namespace Disco.Models.UI.Config.DeviceModel
{
public interface ConfigDeviceModelShowModel : BaseUIModel
public interface ConfigDeviceModelShowModel : BaseUIModel, ConfigSharedDeviceGroupDocumentTemplateBulkGenerate
{
Disco.Models.Repository.DeviceModel DeviceModel { get; set; }
@@ -1,9 +1,10 @@
using Disco.Models.BI.Config;
using Disco.Models.UI.Config.Shared;
using System.Collections.Generic;
namespace Disco.Models.UI.Config.DeviceProfile
{
public interface ConfigDeviceProfileShowModel : BaseUIModel
public interface ConfigDeviceProfileShowModel : BaseUIModel, ConfigSharedDeviceGroupDocumentTemplateBulkGenerate
{
Repository.DeviceProfile DeviceProfile { get; set; }
OrganisationAddress DefaultOrganisationAddress { get; set; }
@@ -0,0 +1,22 @@
using System.Collections.Generic;
namespace Disco.Models.UI.Config.DocumentTemplate
{
public interface ConfigDocumentTemplateBulkGenerate : BaseUIModel
{
Repository.DocumentTemplate DocumentTemplate { get; set; }
int TemplatePageCount { get; set; }
List<ItemWithCount<Repository.UserFlag>> UserFlags { get; set; }
List<ItemWithCount<Repository.DeviceProfile>> DeviceProfiles { get; set; }
List<ItemWithCount<Repository.DeviceBatch>> DeviceBatches { get; set; }
List<ItemWithCount<Repository.DocumentTemplate>> DocumentTemplates { get; set; }
List<ItemWithCount<string>> UserDetails { get; set; }
}
public class ItemWithCount<T>
{
public T Item { get; set; }
public int Count { get; set; }
}
}
@@ -14,7 +14,7 @@ namespace Disco.Models.UI.Config.DocumentTemplate
List<string> Scopes { get; }
List<Repository.JobType> GetJobTypes { get; }
List<Repository.JobSubType> GetJobSubTypes { get; }
List<Repository.JobType> GetJobTypes();
List<Repository.JobSubType> GetJobSubTypes();
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Disco.Models.Services.Documents;
using System.Collections.Generic;
namespace Disco.Models.UI.Config.DocumentTemplate
{
@@ -8,6 +9,11 @@ namespace Disco.Models.UI.Config.DocumentTemplate
int StoredInstanceCount { get; set; }
List<bool> TemplatePagesHaveAttachmentId { get; set; }
int TemplatePageCount { get; }
string BulkGenerateDownloadId { get; }
string BulkGenerateDownloadFilename { get; }
List<Repository.UserFlag> UserFlags { get; set; }
List<OnImportUserFlagRule> OnImportUserFlagRules { get; }
List<Repository.JobType> JobTypes { get; set; }
@@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace Disco.Models.UI.Config.Shared
{
public interface ConfigSharedDeviceGroupDocumentTemplateBulkGenerate : BaseUIModel
{
List<Repository.DocumentTemplate> BulkGenerateDocumentTemplates { get; set; }
int DeviceGroupId { get; }
}
}
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.Config.Shared
namespace Disco.Models.UI.Config.Shared
{
public interface ConfigSharedTaskStatusModel : BaseUIModel
{
@@ -20,5 +20,7 @@ namespace Disco.Models.UI.Device
List<Repository.DocumentTemplate> DocumentTemplates { get; set; }
List<DocumentTemplatePackage> DocumentTemplatePackages { get; set; }
Dictionary<string, string> AssignedUserDetails { get; set; }
bool HasAssignedUserPhoto { get; set; }
}
}
+2
View File
@@ -17,5 +17,7 @@ namespace Disco.Models.UI.Job
LocationModes LocationMode { get; set; }
List<JobLocationReference> LocationOptions { get; set; }
Dictionary<string, string> UserDetails { get; set; }
bool HasUserPhoto { get; set; }
}
}
+2
View File
@@ -17,5 +17,7 @@ namespace Disco.Models.UI.User
IAuthorizationToken AuthorizationToken { get; set; }
IClaimNavigatorItem ClaimNavigator { get; set; }
Dictionary<string, string> UserDetails { get; set; }
bool HasUserPhoto { get; set; }
}
}
+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="net45" />
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net45" />
</packages>
@@ -11,15 +11,15 @@
</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" />
<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" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.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" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
@@ -29,6 +29,10 @@
<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="Microsoft.AspNet.SignalR.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.1.0" newVersion="2.1.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -32,5 +32,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.0.16320.1300")]
[assembly: AssemblyFileVersion("2.0.16320.1300")]
[assembly: AssemblyVersion("2.0.16326.0500")]
[assembly: AssemblyFileVersion("2.0.16326.0500")]
+3 -3
View File
@@ -30,7 +30,7 @@
</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" />
<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" />
@@ -42,11 +42,11 @@
</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" />
<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" />
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
@@ -3,7 +3,6 @@ using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Documents.ManagedGroups;
using Disco.Services.Users;
using Exceptionless;
using System;
using System.Drawing;
using System.IO;
@@ -38,6 +37,21 @@ namespace Disco.Services
DocumentTemplateManagedGroups.TriggerDeviceAttachmentDeleted(Database, attachmentId, documentTemplateId, deviceSerialNumber);
}
public static bool CanDelete(this DeviceBatchAttachment attachment)
{
if (UserService.CurrentAuthorization.Has(Claims.Config.DeviceBatch.Configure))
return true;
return false;
}
public static void OnDelete(this DeviceBatchAttachment attachment, DiscoDataContext Database)
{
if (!attachment.CanDelete())
throw new InvalidOperationException("Deletion of Attachment is Denied");
attachment.RepositoryDelete(Database);
Database.DeviceBatchAttachments.Remove(attachment);
}
public static bool CanDelete(this JobAttachment ja)
{
if (UserService.CurrentAuthorization.Has(Claims.Job.Actions.RemoveAnyAttachments))
@@ -91,6 +105,9 @@ namespace Disco.Services
#endregion
public static DeviceAttachment CreateAttachment(this Device Device, DiscoDataContext Database, User CreatorUser, string Filename, string MimeType, string Comments, Stream Content, DocumentTemplate DocumentTemplate = null, Image PdfThumbnail = null)
=> Device.CreateAttachment(Database, CreatorUser, Filename, DateTime.Now, MimeType, Comments, Content, DocumentTemplate, PdfThumbnail);
public static DeviceAttachment CreateAttachment(this Device Device, DiscoDataContext Database, User CreatorUser, string Filename, DateTime timestamp, string MimeType, string Comments, Stream Content, DocumentTemplate DocumentTemplate = null, Image PdfThumbnail = null, string HandlerId = null, string HandlerReferenceId = null, string HandlerData = null)
{
if (string.IsNullOrEmpty(MimeType) || MimeType.Equals("unknown/unknown", StringComparison.OrdinalIgnoreCase))
MimeType = Interop.MimeTypes.ResolveMimeType(Filename);
@@ -101,8 +118,11 @@ namespace Disco.Services
TechUserId = CreatorUser.UserId,
Filename = Filename,
MimeType = MimeType,
Timestamp = DateTime.Now,
Comments = Comments
Timestamp = timestamp,
Comments = Comments,
HandlerId = HandlerId,
HandlerReferenceId = HandlerReferenceId,
HandlerData = HandlerData,
};
if (DocumentTemplate != null)
@@ -122,6 +142,9 @@ namespace Disco.Services
}
public static JobAttachment CreateAttachment(this Job Job, DiscoDataContext Database, User CreatorUser, string Filename, string MimeType, string Comments, Stream Content, DocumentTemplate DocumentTemplate = null, Image PdfThumbnail = null)
=> Job.CreateAttachment(Database, CreatorUser, Filename, DateTime.Now, MimeType, Comments, Content, DocumentTemplate, PdfThumbnail);
public static JobAttachment CreateAttachment(this Job Job, DiscoDataContext Database, User CreatorUser, string Filename, DateTime Timestamp, string MimeType, string Comments, Stream Content, DocumentTemplate DocumentTemplate = null, Image PdfThumbnail = null, string HandlerId = null, string HandlerReferenceId = null, string HandlerData = null)
{
if (string.IsNullOrEmpty(MimeType) || MimeType.Equals("unknown/unknown", StringComparison.OrdinalIgnoreCase))
MimeType = Interop.MimeTypes.ResolveMimeType(Filename);
@@ -132,8 +155,11 @@ namespace Disco.Services
TechUserId = CreatorUser.UserId,
Filename = Filename,
MimeType = MimeType,
Timestamp = DateTime.Now,
Comments = Comments
Timestamp = Timestamp,
Comments = Comments,
HandlerId = HandlerId,
HandlerReferenceId = HandlerReferenceId,
HandlerData = HandlerData,
};
if (DocumentTemplate != null)
@@ -153,6 +179,9 @@ namespace Disco.Services
}
public static UserAttachment CreateAttachment(this User User, DiscoDataContext Database, User CreatorUser, string Filename, string MimeType, string Comments, Stream Content, DocumentTemplate DocumentTemplate = null, Image PdfThumbnail = null)
=> User.CreateAttachment(Database, CreatorUser, Filename, DateTime.Now, MimeType, Comments, Content, DocumentTemplate, PdfThumbnail);
public static UserAttachment CreateAttachment(this User User, DiscoDataContext Database, User CreatorUser, string Filename, DateTime Timestamp, string MimeType, string Comments, Stream Content, DocumentTemplate DocumentTemplate = null, Image PdfThumbnail = null, string HandlerId = null, string HandlerReferenceId = null, string HandlerData = null)
{
if (string.IsNullOrEmpty(MimeType) || MimeType.Equals("unknown/unknown", StringComparison.OrdinalIgnoreCase))
MimeType = Interop.MimeTypes.ResolveMimeType(Filename);
@@ -163,8 +192,11 @@ namespace Disco.Services
TechUserId = CreatorUser.UserId,
Filename = Filename,
MimeType = MimeType,
Timestamp = DateTime.Now,
Comments = Comments
Timestamp = Timestamp,
Comments = Comments,
HandlerId = HandlerId,
HandlerReferenceId = HandlerReferenceId,
HandlerData = HandlerData,
};
if (DocumentTemplate != null)
@@ -234,10 +266,7 @@ namespace Disco.Services
return true;
}
}
catch (Exception ex)
{
ex.ToExceptionless().Submit();
}
catch (Exception) { }
}
@@ -266,10 +295,7 @@ namespace Disco.Services
}
}
}
catch (Exception ex)
{
ex.ToExceptionless().Submit();
}
catch (Exception) { }
}
}
Thumbnail = null;
@@ -9,39 +9,45 @@ namespace Disco.Services
public static class AttachmentDataStoreExtensions
{
public static string RepositoryFilename(this IAttachment Attachment, DiscoDataContext Database)
public static string RepositoryFilename(this IAttachment attachment, DiscoDataContext database)
{
switch (Attachment.AttachmentType)
switch (attachment.AttachmentType)
{
case AttachmentTypes.Device:
return Path.Combine(DataStore.CreateLocation(Database, "DeviceAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_file", Attachment.Reference, Attachment.Id));
return Path.Combine(DataStore.CreateLocation(database, "DeviceAttachments", attachment.Timestamp),
$"{attachment.Reference}_{attachment.Id}_file");
case AttachmentTypes.DeviceBatch:
return Path.Combine(DataStore.CreateLocation(database, "DeviceBatchAttachments", attachment.Timestamp),
$"{attachment.Reference}_{attachment.Id}_file");
case AttachmentTypes.Job:
return Path.Combine(DataStore.CreateLocation(Database, "JobAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_file", Attachment.Reference, Attachment.Id));
return Path.Combine(DataStore.CreateLocation(database, "JobAttachments", attachment.Timestamp),
$"{attachment.Reference}_{attachment.Id}_file");
case AttachmentTypes.User:
return Path.Combine(DataStore.CreateLocation(Database, "UserAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_file", ((string)Attachment.Reference).Replace('\\', '_'), Attachment.Id));
return Path.Combine(DataStore.CreateLocation(database, "UserAttachments", attachment.Timestamp),
$"{((string)attachment.Reference).Replace('\\', '_')}_{attachment.Id}_file");
default:
throw new ArgumentException("Unknown Attachment Type", nameof(Attachment));
throw new ArgumentException("Unknown Attachment Type", nameof(attachment));
}
}
public static string RepositoryThumbnailFilename(this IAttachment Attachment, DiscoDataContext Database)
public static string RepositoryThumbnailFilename(this IAttachment attachment, DiscoDataContext database)
{
switch (Attachment.AttachmentType)
switch (attachment.AttachmentType)
{
case AttachmentTypes.Device:
return Path.Combine(DataStore.CreateLocation(Database, "DeviceAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_thumb.jpg", Attachment.Reference, Attachment.Id));
return Path.Combine(DataStore.CreateLocation(database, "DeviceAttachments", attachment.Timestamp),
$"{attachment.Reference}_{attachment.Id}_thumb.jpg");
case AttachmentTypes.DeviceBatch:
return Path.Combine(DataStore.CreateLocation(database, "DeviceBatchAttachments", attachment.Timestamp),
$"{attachment.Reference}_{attachment.Id}_thumb.jpg");
case AttachmentTypes.Job:
return Path.Combine(DataStore.CreateLocation(Database, "JobAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_thumb.jpg", Attachment.Reference, Attachment.Id));
return Path.Combine(DataStore.CreateLocation(database, "JobAttachments", attachment.Timestamp),
$"{attachment.Reference}_{attachment.Id}_thumb.jpg");
case AttachmentTypes.User:
return Path.Combine(DataStore.CreateLocation(Database, "UserAttachments", Attachment.Timestamp),
string.Format("{0}_{1}_thumb.jpg", ((string)Attachment.Reference).Replace('\\', '_'), Attachment.Id));
return Path.Combine(DataStore.CreateLocation(database, "UserAttachments", attachment.Timestamp),
$"{((string)attachment.Reference).Replace('\\', '_')}_{attachment.Id}_thumb.jpg");
default:
throw new ArgumentException("Unknown Attachment Type", nameof(Attachment));
throw new ArgumentException("Unknown Attachment Type", nameof(attachment));
}
}
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Authorization
{
@@ -13,21 +9,21 @@ namespace Disco.Services.Authorization
public AccessDeniedException(string Message, string Resource)
{
this.message = Message;
this.resource = Resource;
message = Message;
resource = Resource;
}
public override string Message
{
get
{
if (this.message == null)
if (message == null)
{
return "Your account does not have the required permission to access this Disco feature.";
}
else
{
return this.message;
return message;
}
}
}
@@ -36,7 +32,7 @@ namespace Disco.Services.Authorization
{
get
{
return this.resource;
return resource;
}
}
}
@@ -1,11 +1,7 @@
using Disco.Models.Repository;
using Disco.Services.Logging;
using Disco.Services.Logging.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Authorization
{
@@ -5,9 +5,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.Services.Interop.ActiveDirectory;
namespace Disco.Services.Authorization
{
@@ -3,8 +3,6 @@ using Disco.Services.Authorization.Roles;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Authorization
{
@@ -26,9 +24,9 @@ namespace Disco.Services.Authorization
{
this.Key = Key;
var details = Claims.GetClaimDetails(Key);
this.Name = details.Item1;
this.Description = details.Item2;
this.accessor = Claims.GetClaimAccessor(Key);
Name = details.Item1;
Description = details.Item2;
accessor = Claims.GetClaimAccessor(Key);
this.Hidden = Hidden;
}
@@ -52,13 +50,13 @@ namespace Disco.Services.Authorization
{
return new ClaimNavigatorItem()
{
Key = this.Key,
Name = this.Name,
Description = this.Description,
Hidden = this.Hidden,
accessor = this.accessor,
Value = this.accessor == null ? (bool?)null : this.accessor(RoleClaims),
Children = this.Children == null ? null : this.Children.Cast<ClaimNavigatorItem>().Select(c => c.BuildClaimTree(RoleClaims)).ToList()
Key = Key,
Name = Name,
Description = Description,
Hidden = Hidden,
accessor = accessor,
Value = accessor == null ? (bool?)null : accessor(RoleClaims),
Children = Children == null ? null : Children.Cast<ClaimNavigatorItem>().Select(c => c.BuildClaimTree(RoleClaims)).ToList()
};
}
@@ -66,19 +64,19 @@ namespace Disco.Services.Authorization
{
return new ClaimNavigatorItem()
{
Key = this.Key,
Name = this.Name,
Description = this.Description,
Hidden = this.Hidden,
accessor = this.accessor,
Value = this.accessor == null ? (bool?)null : RoleClaims.Any(rc => this.accessor(rc)),
Children = this.Children == null ? null : this.Children.Cast<ClaimNavigatorItem>().Select(c => c.BuildClaimTree(RoleClaims)).ToList()
Key = Key,
Name = Name,
Description = Description,
Hidden = Hidden,
accessor = accessor,
Value = accessor == null ? (bool?)null : RoleClaims.Any(rc => accessor(rc)),
Children = Children == null ? null : Children.Cast<ClaimNavigatorItem>().Select(c => c.BuildClaimTree(RoleClaims)).ToList()
};
}
public override string ToString()
{
return string.Format("{0}: {1}={2}", this.Name, this.Key, this.Value);
return string.Format("{0}: {1}={2}", Name, Key, Value);
}
}
}
+8
View File
@@ -60,6 +60,7 @@ namespace Disco.Services.Authorization
{ "Config.Plugin.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Plugin.Show, (c, v) => c.Config.Plugin.Show = v, "Show Plugins", "Can show plugins", false) },
{ "Config.Plugin.Uninstall", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Plugin.Uninstall, (c, v) => c.Config.Plugin.Uninstall = v, "Uninstall Plugins", "Can uninstall plugins", false) },
{ "Config.System.ConfigureActiveDirectory", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureActiveDirectory, (c, v) => c.Config.System.ConfigureActiveDirectory = v, "Configure Active Directory Settings", "Can configure the Active Directory interoperability settings", false) },
{ "Config.System.ConfigureEmail", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureEmail, (c, v) => c.Config.System.ConfigureEmail = v, "Configure Email Settings", "Can configure the email settings", false) },
{ "Config.System.ConfigureProxy", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.ConfigureProxy, (c, v) => c.Config.System.ConfigureProxy = v, "Configure Proxy Settings", "Can configure the proxy settings", false) },
{ "Config.System.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.System.Show, (c, v) => c.Config.System.Show = v, "Show System Configuration", "Can show the system configuration", false) },
{ "Config.Organisation.ConfigureAddresses", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Organisation.ConfigureAddresses, (c, v) => c.Config.Organisation.ConfigureAddresses = v, "Configure Addresses", "Can configure organisation addresses", false) },
@@ -297,6 +298,7 @@ namespace Disco.Services.Authorization
}),
new ClaimNavigatorItem("Config.System", "System", "Permissions related to System Configuration", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.System.ConfigureActiveDirectory", false),
new ClaimNavigatorItem("Config.System.ConfigureEmail", false),
new ClaimNavigatorItem("Config.System.ConfigureProxy", false),
new ClaimNavigatorItem("Config.System.Show", false)
}),
@@ -574,6 +576,7 @@ namespace Disco.Services.Authorization
c.Config.Plugin.Show = true;
c.Config.Plugin.Uninstall = true;
c.Config.System.ConfigureActiveDirectory = true;
c.Config.System.ConfigureEmail = true;
c.Config.System.ConfigureProxy = true;
c.Config.System.Show = true;
c.Config.Organisation.ConfigureAddresses = true;
@@ -993,6 +996,11 @@ namespace Disco.Services.Authorization
/// </summary>
public const string ConfigureActiveDirectory = "Config.System.ConfigureActiveDirectory";
/// <summary>Configure Email Settings
/// <para>Can configure the email settings</para>
/// </summary>
public const string ConfigureEmail = "Config.System.ConfigureEmail";
/// <summary>Configure Proxy Settings
/// <para>Can configure the proxy settings</para>
/// </summary>
@@ -1,10 +1,4 @@
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System;
namespace Disco.Services.Authorization
{
@@ -17,7 +11,7 @@ namespace Disco.Services.Authorization
if (AuthorisedClaims == null || AuthorisedClaims.Length == 0)
throw new ArgumentNullException("AuthorisedClaims");
this.authorizedClaims = AuthorisedClaims;
authorizedClaims = AuthorisedClaims;
}
public override bool IsAuthorized(System.Web.HttpContextBase httpContext)
@@ -1,10 +1,4 @@
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System;
namespace Disco.Services.Authorization
{
@@ -17,7 +11,7 @@ namespace Disco.Services.Authorization
if (AuthorisedClaims == null || AuthorisedClaims.Length == 0)
throw new ArgumentNullException("AuthorisedClaims");
this.authorizedClaims = AuthorisedClaims;
authorizedClaims = AuthorisedClaims;
}
public override bool IsAuthorized(System.Web.HttpContextBase httpContext)
@@ -1,10 +1,4 @@
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace Disco.Services.Authorization
{
@@ -16,7 +10,7 @@ namespace Disco.Services.Authorization
public DiscoAuthorizeAttribute(string AuthorisedClaim)
{
this.authorizedClaim = AuthorisedClaim;
authorizedClaim = AuthorisedClaim;
}
public override bool IsAuthorized(System.Web.HttpContextBase httpContext)
@@ -1,10 +1,6 @@
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace Disco.Services.Authorization
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles
namespace Disco.Services.Authorization.Roles
{
public abstract class BaseRoleClaimGroup
{
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles
{

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