Compare commits
242 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e2c07f019c | |||
| 7603cac01a | |||
| 356762c811 | |||
| deaac0f073 | |||
| de10f92c02 | |||
| 3e514fdf9a | |||
| 36c24542e1 | |||
| ca7193a8fc | |||
| 676ff82e4b | |||
| 53fdea5325 | |||
| 0c0a7bf297 | |||
| 57aeaa3eaa | |||
| d291ad464f | |||
| be7ee4cae8 | |||
| 7deead494b | |||
| fd43d85778 | |||
| 4c27b0ff3c | |||
| 58546ed16d | |||
| 9656c15c4b | |||
| 1add4ee0f5 | |||
| 5792771ea1 | |||
| 49da389c2c | |||
| 7faebe56a8 | |||
| 4e518d6684 | |||
| b4e54c9edf | |||
| 3aeb9374a9 | |||
| 0905a02aea | |||
| f8fd1a58a3 | |||
| 2184c9e22e | |||
| 42e9045d5e | |||
| 092c6249ee | |||
| b56e82d5c4 | |||
| 54a578f4a1 | |||
| 3f1fa3d7de | |||
| caa0bedc93 | |||
| 6e99b4503b | |||
| 583552ffdd | |||
| 4660425ccc | |||
| 8b8b26116e | |||
| 57ae665070 | |||
| f06a37ebb4 | |||
| ee273ffe03 | |||
| 0672bdb7c0 | |||
| 662e1ed231 | |||
| cc1f224456 | |||
| 6e2c36d4ae | |||
| bccbb20b84 | |||
| fd3eb80648 | |||
| 9a171a8417 | |||
| eb1ffae212 | |||
| d31c2db43b | |||
| 62a5da7513 | |||
| eb3ed7f819 | |||
| a9687b5f25 | |||
| 539503133a | |||
| d2b5e7ab6a | |||
| 04430bba50 | |||
| 162ca20046 | |||
| 786d4809b5 | |||
| d3cef11796 | |||
| 2c215e4856 | |||
| eec8ba438c | |||
| 59dc0b9d5a | |||
| ac24055365 | |||
| 2fce645066 | |||
| 67f1c2a5d1 | |||
| f946f3250c | |||
| 0853bcee50 | |||
| 408e1c4c14 | |||
| dee54bb6d7 | |||
| 50603210b0 | |||
| b640e51874 | |||
| 7a336e699a | |||
| a3e1e1d030 | |||
| 963970feeb | |||
| 296f7a13fd | |||
| 4006bdbcc6 | |||
| 26bac92e5a | |||
| b6dfaa3445 | |||
| 39ba206831 | |||
| 7550e0e45d | |||
| 9f10eeeb70 | |||
| 77acf0bfdb | |||
| f0dfe45cd4 | |||
| fb6432a5c8 | |||
| b15917254f | |||
| 8abe31f430 | |||
| a6b9cd1af2 | |||
| 90c709c4c1 | |||
| 25e3a8e1f1 | |||
| 343f20980d | |||
| f36871abe2 | |||
| cb354cd13e | |||
| 09f9f2d427 | |||
| 390857e065 | |||
| e0d620bf67 | |||
| 78b7b059ea | |||
| bb846d14c5 | |||
| 565e1707ce | |||
| a675e4a6e9 | |||
| d8eb8fec83 | |||
| f90eda4101 | |||
| 37e2e5a08c | |||
| 6af83cbdb2 | |||
| 5f4cb20900 | |||
| aee467cb53 | |||
| 6ce6e2cccf | |||
| cd858c2215 | |||
| 7e07c07171 | |||
| 15e2806731 | |||
| 53baf4eb78 | |||
| 8c48ab6ecd | |||
| 8afe4195a9 | |||
| dcc4fcb984 | |||
| 4631903019 | |||
| 85d51c0e45 | |||
| 974a07f3bb | |||
| b576aec641 | |||
| a2aaa4c913 | |||
| 318a70d9a3 | |||
| 53e57d4017 | |||
| 143dc1b3e6 | |||
| a4f18d1d49 | |||
| 46222f2a78 | |||
| 2e091383ec | |||
| 7ace4d1c7e | |||
| f901d45d78 | |||
| 028d1ccc64 | |||
| 7b6a44921d | |||
| 23406e5e39 | |||
| 83557e6f0c | |||
| 1c90c89158 | |||
| 9924153e82 | |||
| 3ec2ea7d37 | |||
| b6945d9bbd | |||
| 6740a7479a | |||
| a3fb09440d | |||
| 7353405b16 | |||
| 6fcb1a1eae | |||
| e204ea4d5f | |||
| 0a4a2816a0 | |||
| 473b02f718 | |||
| 5a2c29ea0b | |||
| 1a8ec32f0f | |||
| 9e7daf2043 | |||
| 0c690cff5a | |||
| b55b77de9f | |||
| 937508c440 | |||
| cfe4c4b912 | |||
| d75663a219 | |||
| 1e24844e88 | |||
| 273b67c422 | |||
| 13549e7ec4 | |||
| bbb40bd5c4 | |||
| 22dad072b9 | |||
| 215e9863a2 | |||
| 190abc72dd | |||
| af75a55d44 | |||
| e05206d405 | |||
| 53eed02a4f | |||
| 57a7f67c3a | |||
| 47e11c0fd6 | |||
| 708ca16de8 | |||
| 535a3f2967 | |||
| ebd1c79f64 | |||
| 7194dd612d | |||
| 584bc07824 | |||
| 2bd9238090 | |||
| b11fa5b1d6 | |||
| 7667eaa49e | |||
| 9f7c0f965e | |||
| a274a33cf6 | |||
| 4acfd54319 | |||
| 941f1cf13e | |||
| f225edd2d4 | |||
| 5824680e2a | |||
| ed4ec890da | |||
| 56453fa081 | |||
| 11c824518f | |||
| d720303a83 | |||
| 02b29948ce | |||
| a152365312 | |||
| dba6c383f6 | |||
| ba32b3b717 | |||
| 51cebd0706 | |||
| 983bdbefb9 | |||
| be99083d6a | |||
| 4c19a1ef63 | |||
| 4f9f0fd0a8 | |||
| 05593a1466 | |||
| 2873b4be8a | |||
| 7a1ff211a0 | |||
| fcf70f724e | |||
| 99be87ed9c | |||
| 261baf669e | |||
| b0fddd491b | |||
| dff47c0e8b | |||
| ed58619919 | |||
| 2a2731b9f3 | |||
| 13e666d95a | |||
| 96cccab958 | |||
| e463a7361e | |||
| 58e467b6d6 | |||
| 81bd6ccd83 | |||
| 3e7db6b552 | |||
| 09a6369693 | |||
| 9bfeff8c42 | |||
| 3e57af394d | |||
| e11d0871c4 | |||
| f7fdfb0c8a | |||
| 806aadd161 | |||
| af4a94870e | |||
| 486ce17857 | |||
| f82b47dd46 | |||
| f1d27732c7 | |||
| 28e5901929 | |||
| e531ffe2b7 | |||
| 4fca015afa | |||
| a80ed14038 | |||
| f3e0939a06 | |||
| 2cd6ddfa24 | |||
| b4a30061e3 | |||
| cb033c0b70 | |||
| 3c197e7b2f | |||
| 9f62da9ccd | |||
| df721d7d6e | |||
| 8278efb9a6 | |||
| d477ad5d9c | |||
| 0755b6fc8a | |||
| 78dd494304 | |||
| 0497e145ea | |||
| 4d6aa18095 | |||
| fdf1bd4bc6 | |||
| 82183f6508 | |||
| d6ee70b860 | |||
| 5ce9e51ae7 | |||
| ed66f4f285 | |||
| 526f8547f7 | |||
| d8e93cb31b | |||
| 5fa74a8cc0 | |||
| a0d643eda1 | |||
| 0887eb447e |
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# VSSpell001: Spell Check
|
||||
dotnet_diagnostic.VSSpell001.severity = suggestion
|
||||
@@ -8,8 +8,8 @@ using Disco.Services.Expressions;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using iTextSharp.text.pdf;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -17,76 +17,103 @@ 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)
|
||||
public static Tuple<Dictionary<string, Expression>, List<DocumentField>> CreateExpressions(string templateFileName, 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>();
|
||||
|
||||
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 List<Expression> ExtractPdfExpressions(this DocumentTemplate dt, DiscoDataContext Database)
|
||||
private static Tuple<Dictionary<string, Expression>, List<DocumentField>> CreateExpressions(DocumentTemplate dt, DiscoDataContext database)
|
||||
{
|
||||
return dt.PdfExpressionsFromCache(Database).Values.OrderBy(e => e.Ordinal).ToList();
|
||||
string templateFileName = dt.RepositoryFilename(database);
|
||||
return CreateExpressions(templateFileName, database);
|
||||
}
|
||||
|
||||
public static Stream GeneratePdfBulk(this DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, params string[] DataObjectsIds)
|
||||
public static Dictionary<string, Expression> PdfExpressionsFromCache(this DocumentTemplate dt, DiscoDataContext database)
|
||||
{
|
||||
return Interop.Pdf.PdfGenerator.GenerateBulkFromTemplate(dt, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjectsIds);
|
||||
return ExpressionCache.GetOrCreateExpressions(dt, () => CreateExpressions(dt, database));
|
||||
}
|
||||
public static Stream GeneratePdfBulk(this DocumentTemplate dt, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, params IAttachmentTarget[] DataObjects)
|
||||
|
||||
public static List<DocumentField> PdfFieldsFromCache(this DocumentTemplate dt, DiscoDataContext database)
|
||||
{
|
||||
return Interop.Pdf.PdfGenerator.GenerateBulkFromTemplate(dt, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjects);
|
||||
return ExpressionCache.GetOrCreateFields(dt, () => CreateExpressions(dt, database));
|
||||
}
|
||||
public static Stream GeneratePdf(this DocumentTemplate dt, DiscoDataContext Database, IAttachmentTarget Target, User CreatorUser, DateTime TimeStamp, DocumentState State, bool FlattenFields = false)
|
||||
|
||||
public static List<Expression> ExtractPdfExpressions(this DocumentTemplate dt, DiscoDataContext database)
|
||||
{
|
||||
return dt.PdfExpressionsFromCache(database).Values.OrderBy(e => e.Ordinal).ToList();
|
||||
}
|
||||
|
||||
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);
|
||||
string generateExpressionResult = null;
|
||||
|
||||
if (generateExpression)
|
||||
generateExpressionResult = dt.EvaluateOnGenerateExpression(Target, Database, CreatorUser, TimeStamp, State);
|
||||
generateExpressionResult = dt.EvaluateOnGenerateExpression(target, database, creatorUser, timeStamp, state);
|
||||
|
||||
var pdfStream = Interop.Pdf.PdfGenerator.GenerateFromTemplate(dt, Database, Target, CreatorUser, TimeStamp, State, FlattenFields);
|
||||
var pdfStream = Interop.Pdf.PdfGenerator.GenerateFromTemplate(dt, database, target, creatorUser, timeStamp, state, flattenFields);
|
||||
|
||||
if (generateExpression)
|
||||
DocumentsLog.LogDocumentGenerated(dt, Target, CreatorUser, generateExpressionResult);
|
||||
DocumentsLog.LogDocumentGenerated(dt, target, creatorUser, generateExpressionResult);
|
||||
else
|
||||
DocumentsLog.LogDocumentGenerated(dt, Target, CreatorUser);
|
||||
DocumentsLog.LogDocumentGenerated(dt, target, creatorUser);
|
||||
|
||||
return pdfStream;
|
||||
}
|
||||
public static Stream GeneratePdfPackage(this DocumentTemplatePackage package, DiscoDataContext Database, IAttachmentTarget Target, User CreatorUser, DateTime TimeStamp, DocumentState State)
|
||||
public static Stream GeneratePdfPackage(this DocumentTemplatePackage package, DiscoDataContext database, IAttachmentTarget target, User creatorUser, DateTime timeStamp, DocumentState state)
|
||||
{
|
||||
return Interop.Pdf.PdfGenerator.GenerateFromPackage(package, Database, Target, CreatorUser, TimeStamp, State);
|
||||
return Interop.Pdf.PdfGenerator.GenerateFromPackage(package, database, target, creatorUser, timeStamp, state);
|
||||
}
|
||||
public static Stream GeneratePdfPackageBulk(this DocumentTemplatePackage package, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, List<string> DataObjectsIds)
|
||||
public static Stream GeneratePdfPackageBulk(this DocumentTemplatePackage package, DiscoDataContext database, User creatorUser, DateTime timestamp, bool? insertBlankPages, List<string> dataObjectsIds)
|
||||
{
|
||||
return Interop.Pdf.PdfGenerator.GenerateBulkFromPackage(package, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjectsIds);
|
||||
return Interop.Pdf.PdfGenerator.GenerateBulkFromPackage(package, database, creatorUser, timestamp, insertBlankPages, dataObjectsIds);
|
||||
}
|
||||
public static Stream GeneratePdfPackageBulk(this DocumentTemplatePackage package, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, List<IAttachmentTarget> DataObjects)
|
||||
public static Stream GeneratePdfPackageBulk(this DocumentTemplatePackage package, DiscoDataContext database, User creatorUser, DateTime timestamp, bool? insertBlankPages, List<IAttachmentTarget> dataObjects)
|
||||
{
|
||||
return Interop.Pdf.PdfGenerator.GenerateBulkFromPackage(package, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjects);
|
||||
return Interop.Pdf.PdfGenerator.GenerateBulkFromPackage(package, database, creatorUser, timestamp, insertBlankPages, dataObjects);
|
||||
}
|
||||
|
||||
public static List<bool> PdfPageHasAttachmentId(this DocumentTemplate dt, DiscoDataContext Database)
|
||||
public static List<bool> PdfPageHasAttachmentId(this DocumentTemplate dt, DiscoDataContext database)
|
||||
{
|
||||
string templateFilename = dt.RepositoryFilename(Database);
|
||||
string templateFilename = dt.RepositoryFilename(database);
|
||||
if (!File.Exists(templateFilename))
|
||||
throw new FileNotFoundException("PDF template not found", templateFilename);
|
||||
|
||||
@@ -105,30 +132,20 @@ namespace Disco.BI.Extensions
|
||||
public static void Delete(this DocumentTemplate dt, DiscoDataContext Database)
|
||||
{
|
||||
// Find & Rename all references
|
||||
foreach (DeviceAttachment a in Database.DeviceAttachments.Where(a => a.DocumentTemplateId == dt.Id))
|
||||
void updateAttachment(IAttachment a)
|
||||
{
|
||||
a.Comments = string.Format("{0} - {1}", dt.Description, a.Comments);
|
||||
if (a.Comments.Length > 500)
|
||||
a.Comments = a.Comments.Substring(0, 500);
|
||||
var comments = $"{dt.Description} - {a.Comments}";
|
||||
if (comments.Length > 500)
|
||||
comments = comments.Substring(0, 500);
|
||||
a.Comments = comments;
|
||||
a.DocumentTemplateId = null;
|
||||
a.DocumentTemplate = null;
|
||||
}
|
||||
foreach (JobAttachment a in Database.JobAttachments.Where(a => a.DocumentTemplateId == dt.Id))
|
||||
{
|
||||
a.Comments = string.Format("{0} - {1}", dt.Description, a.Comments);
|
||||
if (a.Comments.Length > 500)
|
||||
a.Comments = a.Comments.Substring(0, 500);
|
||||
a.DocumentTemplateId = null;
|
||||
a.DocumentTemplate = null;
|
||||
}
|
||||
foreach (var a in Database.DeviceAttachments.Where(a => a.DocumentTemplateId == dt.Id))
|
||||
updateAttachment(a);
|
||||
foreach (var a in Database.JobAttachments.Where(a => a.DocumentTemplateId == dt.Id))
|
||||
updateAttachment(a);
|
||||
foreach (UserAttachment a in Database.UserAttachments.Where(a => a.DocumentTemplateId == dt.Id))
|
||||
{
|
||||
a.Comments = string.Format("{0} - {1}", dt.Description, a.Comments);
|
||||
if (a.Comments.Length > 500)
|
||||
a.Comments = a.Comments.Substring(0, 500);
|
||||
a.DocumentTemplateId = null;
|
||||
a.DocumentTemplate = null;
|
||||
}
|
||||
updateAttachment(a);
|
||||
|
||||
// Remove Linked Group
|
||||
ActiveDirectory.Context.ManagedGroups.Remove(DocumentTemplateDevicesManagedGroup.GetKey(dt));
|
||||
@@ -139,8 +156,8 @@ namespace Disco.BI.Extensions
|
||||
|
||||
// Delete Template
|
||||
string templateRepositoryFilename = dt.RepositoryFilename(Database);
|
||||
if (System.IO.File.Exists(templateRepositoryFilename))
|
||||
System.IO.File.Delete(templateRepositoryFilename);
|
||||
if (File.Exists(templateRepositoryFilename))
|
||||
File.Delete(templateRepositoryFilename);
|
||||
|
||||
// Remove from Cache
|
||||
dt.FilterExpressionInvalidateCache();
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.BI.Expressions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Documents;
|
||||
using Disco.Models.Services.Expressions.Extensions;
|
||||
using Disco.Services;
|
||||
using Disco.Services.Documents;
|
||||
using Disco.Services.Expressions;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Tasks;
|
||||
using Disco.Services.Users;
|
||||
using iTextSharp.text.pdf;
|
||||
using iTextSharp.text.pdf.codec;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -21,16 +21,16 @@ namespace Disco.BI.Interop.Pdf
|
||||
{
|
||||
public static class PdfGenerator
|
||||
{
|
||||
public static Stream GenerateBulkFromPackage(DocumentTemplatePackage package, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, List<IAttachmentTarget> DataObjects)
|
||||
public static Stream GenerateBulkFromPackage(DocumentTemplatePackage package, DiscoDataContext database, User creatorUser, DateTime timestamp, bool? insertBlankPages, List<IAttachmentTarget> dataObjects)
|
||||
{
|
||||
if (DataObjects.Count > 0)
|
||||
if (dataObjects.Count > 0)
|
||||
{
|
||||
List<Stream> generatedPdfs = new List<Stream>(DataObjects.Count);
|
||||
List<Stream> generatedPdfs = new List<Stream>(dataObjects.Count);
|
||||
using (var state = DocumentState.DefaultState())
|
||||
{
|
||||
foreach (var d in DataObjects)
|
||||
foreach (var d in dataObjects)
|
||||
{
|
||||
generatedPdfs.Add(package.GeneratePdfPackage(Database, d, CreatorUser, Timestamp, state));
|
||||
generatedPdfs.Add(package.GeneratePdfPackage(database, d, creatorUser, timestamp, state));
|
||||
state.SequenceNumber++;
|
||||
state.FlushScopeCache();
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Disco.BI.Interop.Pdf
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream bulkPdf = Utilities.JoinPdfs(package.InsertBlankPages || InsertBlankPages, generatedPdfs);
|
||||
Stream bulkPdf = Utilities.JoinPdfs(insertBlankPages.GetValueOrDefault(package.InsertBlankPages), generatedPdfs);
|
||||
foreach (Stream singlePdf in generatedPdfs)
|
||||
singlePdf.Dispose();
|
||||
return bulkPdf;
|
||||
@@ -50,25 +50,25 @@ namespace Disco.BI.Interop.Pdf
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Stream GenerateBulkFromPackage(DocumentTemplatePackage package, DiscoDataContext Database, User CreatorUser, DateTime Timestamp, bool InsertBlankPages, List<string> DataObjectsIds)
|
||||
public static Stream GenerateBulkFromPackage(DocumentTemplatePackage package, DiscoDataContext database, User creatorUser, DateTime timestamp, bool? insertBlankPages, List<string> dataObjectsIds)
|
||||
{
|
||||
List<IAttachmentTarget> DataObjects;
|
||||
|
||||
switch (package.Scope)
|
||||
{
|
||||
case AttachmentTypes.Device:
|
||||
DataObjects = Database.Devices.Where(d => DataObjectsIds.Contains(d.SerialNumber)).ToList<IAttachmentTarget>();
|
||||
DataObjects = database.Devices.Where(d => dataObjectsIds.Contains(d.SerialNumber)).ToList<IAttachmentTarget>();
|
||||
break;
|
||||
case AttachmentTypes.Job:
|
||||
int[] intDataObjectsIds = DataObjectsIds.Select(i => int.Parse(i)).ToArray();
|
||||
DataObjects = Database.Jobs.Where(j => intDataObjectsIds.Contains(j.Id)).ToList<IAttachmentTarget>();
|
||||
int[] intDataObjectsIds = dataObjectsIds.Select(i => int.Parse(i)).ToArray();
|
||||
DataObjects = database.Jobs.Where(j => intDataObjectsIds.Contains(j.Id)).ToList<IAttachmentTarget>();
|
||||
break;
|
||||
case AttachmentTypes.User:
|
||||
DataObjects = new List<IAttachmentTarget>(DataObjectsIds.Count);
|
||||
for (int idIndex = 0; idIndex < DataObjectsIds.Count; idIndex++)
|
||||
DataObjects = new List<IAttachmentTarget>(dataObjectsIds.Count);
|
||||
for (int idIndex = 0; idIndex < dataObjectsIds.Count; idIndex++)
|
||||
{
|
||||
string dataObjectId = DataObjectsIds[idIndex];
|
||||
var user = UserService.GetUser(ActiveDirectory.ParseDomainAccountId(dataObjectId), Database, true);
|
||||
string dataObjectId = dataObjectsIds[idIndex];
|
||||
var user = UserService.GetUser(ActiveDirectory.ParseDomainAccountId(dataObjectId), database, true);
|
||||
if (user == null)
|
||||
throw new Exception($"Unknown Username specified: {dataObjectId}");
|
||||
DataObjects.Add(user);
|
||||
@@ -78,12 +78,12 @@ namespace Disco.BI.Interop.Pdf
|
||||
throw new InvalidOperationException("Invalid DocumentType Scope");
|
||||
}
|
||||
|
||||
return GenerateBulkFromPackage(package, Database, CreatorUser, Timestamp, InsertBlankPages, DataObjects);
|
||||
return GenerateBulkFromPackage(package, database, creatorUser, timestamp, insertBlankPages, DataObjects);
|
||||
}
|
||||
|
||||
public static Stream GenerateFromPackage(DocumentTemplatePackage package, DiscoDataContext Database, IAttachmentTarget Data, User CreatorUser, DateTime Timestamp, DocumentState State)
|
||||
public static Stream GenerateFromPackage(DocumentTemplatePackage package, DiscoDataContext database, IAttachmentTarget data, User creatorUser, DateTime timestamp, DocumentState state)
|
||||
{
|
||||
var templates = package.GetDocumentTemplates(Database);
|
||||
var templates = package.GetDocumentTemplates(database);
|
||||
|
||||
if (templates.Count == 0)
|
||||
return null;
|
||||
@@ -92,21 +92,21 @@ namespace Disco.BI.Interop.Pdf
|
||||
string generateExpressionResult = null;
|
||||
|
||||
if (generateExpression)
|
||||
generateExpressionResult = package.EvaluateOnGenerateExpression(Data, Database, CreatorUser, Timestamp, State);
|
||||
generateExpressionResult = package.EvaluateOnGenerateExpression(data, database, creatorUser, timestamp, state);
|
||||
|
||||
List<Stream> generatedPdfs = new List<Stream>(templates.Count);
|
||||
foreach (var template in templates)
|
||||
{
|
||||
generatedPdfs.Add(template.GeneratePdf(Database, Data, CreatorUser, Timestamp, State, true));
|
||||
generatedPdfs.Add(template.GeneratePdf(database, data, creatorUser, timestamp, state, true));
|
||||
|
||||
State.SequenceNumber++;
|
||||
State.FlushScopeCache();
|
||||
state.SequenceNumber++;
|
||||
state.FlushScopeCache();
|
||||
}
|
||||
|
||||
if (generateExpression)
|
||||
DocumentsLog.LogDocumentPackageGenerated(package, Data, CreatorUser, generateExpressionResult);
|
||||
DocumentsLog.LogDocumentPackageGenerated(package, data, creatorUser, generateExpressionResult);
|
||||
else
|
||||
DocumentsLog.LogDocumentPackageGenerated(package, Data, CreatorUser);
|
||||
DocumentsLog.LogDocumentPackageGenerated(package, data, creatorUser);
|
||||
|
||||
if (generatedPdfs.Count == 1)
|
||||
{
|
||||
@@ -120,16 +120,20 @@ 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())
|
||||
{
|
||||
foreach (var d in DataObjects)
|
||||
taskStatus.UpdateStatus(10, "Rendering", "Starting");
|
||||
foreach (var d in dataObjects)
|
||||
{
|
||||
generatedPdfs.Add(dt.GeneratePdf(Database, d, CreatorUser, Timestamp, state, true));
|
||||
taskStatus.UpdateStatus(progressDoc += progressPerDoc, $"Rendering {d.AttachmentReferenceId}");
|
||||
generatedPdfs.Add(dt.GeneratePdf(database, d, creatorUser, timestamp, state, true));
|
||||
state.SequenceNumber++;
|
||||
state.FlushScopeCache();
|
||||
}
|
||||
@@ -140,7 +144,8 @@ namespace Disco.BI.Interop.Pdf
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream bulkPdf = Utilities.JoinPdfs(InsertBlankPages, generatedPdfs);
|
||||
taskStatus.UpdateStatus(90, "Merging", "Merging documents");
|
||||
Stream bulkPdf = Utilities.JoinPdfs(insertBlankPages, generatedPdfs);
|
||||
foreach (Stream singlePdf in generatedPdfs)
|
||||
singlePdf.Dispose();
|
||||
return bulkPdf;
|
||||
@@ -149,38 +154,60 @@ 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)
|
||||
public static Stream GenerateFromTemplate(DocumentTemplate dt, DiscoDataContext Database, IAttachmentTarget Data, User CreatorUser, DateTime TimeStamp, DocumentState State, bool flattenFields = false)
|
||||
{
|
||||
// Validate Data
|
||||
switch (dt.Scope)
|
||||
@@ -205,9 +232,9 @@ namespace Disco.BI.Interop.Pdf
|
||||
|
||||
// Override FlattenFields if Document Template instructs.
|
||||
if (dt.FlattenForm)
|
||||
FlattenFields = true;
|
||||
flattenFields = true;
|
||||
|
||||
ConcurrentDictionary<string, Expression> expressionCache = dt.PdfExpressionsFromCache(Database);
|
||||
var expressionCache = dt.PdfExpressionsFromCache(Database);
|
||||
|
||||
string templateFilename = dt.RepositoryFilename(Database);
|
||||
PdfReader pdfReader = new PdfReader(templateFilename);
|
||||
@@ -215,10 +242,10 @@ namespace Disco.BI.Interop.Pdf
|
||||
MemoryStream pdfGeneratedStream = new MemoryStream();
|
||||
PdfStamper pdfStamper = new PdfStamper(pdfReader, pdfGeneratedStream);
|
||||
|
||||
pdfStamper.FormFlattening = FlattenFields;
|
||||
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)
|
||||
{
|
||||
@@ -226,8 +253,8 @@ 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);
|
||||
if (flattenFields)
|
||||
pdfStamper.AcroFields.SetField(pdfFieldKey, string.Empty);
|
||||
else
|
||||
pdfStamper.AcroFields.SetField(pdfFieldKey, fieldValue);
|
||||
|
||||
@@ -241,16 +268,15 @@ namespace Disco.BI.Interop.Pdf
|
||||
var pageUniqueIdBytes = pageUniqueId.ToQRCodeBytes();
|
||||
|
||||
// Encode to QRCode byte array
|
||||
var pageUniqueIdWidth = (int)pdfFieldPosition.position.Width;
|
||||
var pageUniqueIdHeight = (int)pdfFieldPosition.position.Height;
|
||||
var pageUniqueIdEncoded = QRCodeBinaryEncoder.Encode(pageUniqueIdBytes, pageUniqueIdWidth, pageUniqueIdHeight);
|
||||
var pageUniqueIdEncoded = QRCodeBinaryEncoder.Encode(pageUniqueIdBytes, out var qrWidth, out var qrHeight);
|
||||
|
||||
// Encode byte array to Image
|
||||
var pageUniqueIdImageData = CCITTG4Encoder.Compress(pageUniqueIdEncoded, pageUniqueIdWidth, pageUniqueIdHeight);
|
||||
var pageUniqueIdImage = iTextSharp.text.Image.GetInstance(pageUniqueIdWidth, pageUniqueIdHeight, false, 256, 1, pageUniqueIdImageData, null);
|
||||
var pageUniqueIdImageData = CCITTG4Encoder.Compress(pageUniqueIdEncoded, qrWidth, qrHeight);
|
||||
var pageUniqueIdImage = iTextSharp.text.Image.GetInstance(qrWidth, qrHeight, false, 256, 1, pageUniqueIdImageData, null);
|
||||
|
||||
// Add to the pdf page
|
||||
pageUniqueIdImage.SetAbsolutePosition(pdfFieldPosition.position.Left, pdfFieldPosition.position.Bottom);
|
||||
pageUniqueIdImage.ScaleToFit(pdfFieldPosition.position.Width, pdfFieldPosition.position.Height);
|
||||
pdfStamper.GetOverContent(pdfFieldPosition.page).AddImage(pageUniqueIdImage);
|
||||
}
|
||||
// Hide Fields
|
||||
@@ -270,8 +296,7 @@ namespace Disco.BI.Interop.Pdf
|
||||
}
|
||||
else
|
||||
{
|
||||
Expression fieldExpression = null;
|
||||
if (expressionCache.TryGetValue(pdfFieldKey, out fieldExpression))
|
||||
if (expressionCache.TryGetValue(pdfFieldKey, out var fieldExpression))
|
||||
{
|
||||
if (fieldExpression.IsDynamic)
|
||||
{
|
||||
@@ -288,8 +313,24 @@ namespace Disco.BI.Interop.Pdf
|
||||
for (int pdfFieldOrdinal = 0; pdfFieldOrdinal < fields.Size; pdfFieldOrdinal++)
|
||||
{
|
||||
AcroFields.FieldPosition pdfFieldPosition = pdfFieldPositions[pdfFieldOrdinal];
|
||||
iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(imageResult.GetImage((int)pdfFieldPosition.position.Width, (int)pdfFieldPosition.position.Height));
|
||||
|
||||
iTextSharp.text.Image pdfImage;
|
||||
var imageWidth = (int)(pdfFieldPosition.position.Width * 1.6);
|
||||
var imageHeight = (int)(pdfFieldPosition.position.Height * 1.6);
|
||||
if (imageResult.Format == ImageExpressionFormat.Jpeg || imageResult.Format == ImageExpressionFormat.Png)
|
||||
{
|
||||
pdfImage = iTextSharp.text.Image.GetInstance(imageResult.GetImage(imageWidth, imageHeight));
|
||||
}
|
||||
else if (imageResult.Format == ImageExpressionFormat.CcittG4)
|
||||
{
|
||||
var imageData = imageResult.GetImage(out imageWidth, out imageHeight);
|
||||
pdfImage = iTextSharp.text.Image.GetInstance(imageWidth, imageHeight, false, 256, 1, imageData.GetBuffer(), null);
|
||||
}
|
||||
else
|
||||
throw new NotSupportedException($"Unexpected image format {imageResult.Format}");
|
||||
|
||||
pdfImage.SetAbsolutePosition(pdfFieldPosition.position.Left, pdfFieldPosition.position.Bottom);
|
||||
pdfImage.ScaleToFit(pdfFieldPosition.position.Width, pdfFieldPosition.position.Height);
|
||||
pdfStamper.GetOverContent(pdfFieldPosition.page).AddImage(pdfImage);
|
||||
}
|
||||
if (!fieldExpressionResult.Item2 && !imageResult.ShowField)
|
||||
@@ -355,7 +396,7 @@ namespace Disco.BI.Interop.Pdf
|
||||
TechUserId = CreatorUser.UserId,
|
||||
Timestamp = DateTime.Now
|
||||
};
|
||||
jl.Comments = string.Format("# Document Generated\r\n**{0}** [{1}]", dt.Description, dt.Id);
|
||||
jl.Comments = $"# Document Generated\r\n**{dt.Description}** [{dt.Id}]";
|
||||
Database.JobLogs.Add(jl);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
using iTextSharp.text.pdf.codec;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
@@ -7,10 +9,15 @@ namespace Disco.BI.Interop.Pdf
|
||||
{
|
||||
public static class Utilities
|
||||
{
|
||||
public static Func<byte[], int, int, byte[]> GetCCITTG4EncoderCompressDelegate()
|
||||
{
|
||||
return CCITTG4Encoder.Compress;
|
||||
}
|
||||
|
||||
public static Stream JoinPdfs(bool InsertBlankPages, List<Stream> Pdfs)
|
||||
{
|
||||
if (Pdfs.Count == 0)
|
||||
throw new System.ArgumentNullException(nameof(Pdfs));
|
||||
throw new ArgumentNullException(nameof(Pdfs));
|
||||
|
||||
// Only One PDF - Possible Reference Bug v's Memory/Speed (Returning Param Memory Stream)
|
||||
if (Pdfs.Count == 1)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Disco</RootNamespace>
|
||||
<AssemblyName>Disco.BI</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
@@ -53,7 +53,6 @@
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Extensions, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -62,7 +61,6 @@
|
||||
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Web" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyFileVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyVersion("2.5.25262.0000")]
|
||||
[assembly: AssemblyFileVersion("2.5.25262.0000")]
|
||||
+1
-1
@@ -19,7 +19,7 @@ namespace Disco.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
+13
-5
@@ -16,7 +16,7 @@
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
@@ -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,12 +46,20 @@
|
||||
</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="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Disco.Client.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Disco.Client.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Disco.Client
|
||||
{
|
||||
@@ -88,7 +85,7 @@ namespace Disco.Client
|
||||
string reportJson = JsonConvert.SerializeObject(report);
|
||||
string reportResponse;
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ServicePathTemplate);
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ServicePathTemplate);
|
||||
request.UserAgent = $"Disco-Client/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}";
|
||||
request.ContentType = "application/json";
|
||||
request.Method = WebRequestMethods.Http.Post;
|
||||
@@ -108,7 +105,7 @@ namespace Disco.Client
|
||||
}
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("Error Report Logged to Server; Response: {0}", reportResponse);
|
||||
Debug.WriteLine($"Error Report Logged to Server; Response: {reportResponse}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace Disco.Client.Extensions
|
||||
else
|
||||
serviceUrl = string.Format(ServicePathUnauthenticatedTemplate, Service.Feature);
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(serviceUrl);
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUrl);
|
||||
request.UserAgent = $"Disco-Client/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}";
|
||||
request.ContentType = "application/json";
|
||||
request.Method = WebRequestMethods.Http.Post;
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace Disco.Client.Extensions
|
||||
if (!string.IsNullOrEmpty(enrolResponse.ErrorMessage))
|
||||
throw new ClientServiceException("Enrolment", enrolResponse.ErrorMessage);
|
||||
|
||||
if (enrolResponse.IsPending)
|
||||
return;
|
||||
|
||||
// Offline Domain Join
|
||||
bool requireReboot = enrolResponse.ApplyOfflineDomainJoin();
|
||||
|
||||
@@ -101,7 +104,7 @@ namespace Disco.Client.Extensions
|
||||
using (RegistryKey regWinlogon = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true))
|
||||
{
|
||||
regWinlogon.SetValue("DefaultDomainName", enrolResponse.DomainName, RegistryValueKind.String);
|
||||
regWinlogon.SetValue("DefaultUserName", String.Empty, RegistryValueKind.String);
|
||||
regWinlogon.SetValue("DefaultUserName", string.Empty, RegistryValueKind.String);
|
||||
}
|
||||
using (RegistryKey regLogonUI = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI", true))
|
||||
{
|
||||
@@ -130,8 +133,11 @@ namespace Disco.Client.Extensions
|
||||
Presentation.UpdateStatus("Enrolling Device", $"Configuring the device owner:\r\n{enrolResponse.AssignedUserDescription} ({enrolResponse.AssignedUserDomain}\\{enrolResponse.AssignedUserUsername})", true, -1, 3000);
|
||||
|
||||
if (enrolResponse.AssignedUserIsLocalAdmin)
|
||||
Interop.LocalAuthentication.AddLocalGroupMembership("Administrators", enrolResponse.AssignedUserSID, enrolResponse.AssignedUserUsername, enrolResponse.AssignedUserDomain);
|
||||
LocalAuthentication.AddLocalGroupMembership("Administrators", enrolResponse.AssignedUserSID, enrolResponse.AssignedUserUsername, enrolResponse.AssignedUserDomain);
|
||||
}
|
||||
|
||||
if (enrolResponse.SetAssignedUserForLogon && !string.IsNullOrEmpty(enrolResponse.AssignedUserDomain) && !string.IsNullOrEmpty(enrolResponse.AssignedUserUsername))
|
||||
{
|
||||
// Make Windows think this user was the last to logon
|
||||
using (RegistryKey regWinlogon = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true))
|
||||
{
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Disco.Models.ClientServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Disco.Models.ClientServices;
|
||||
|
||||
namespace Disco.Client.Extensions
|
||||
{
|
||||
|
||||
@@ -105,8 +105,7 @@ namespace Disco.Client.Interop
|
||||
{
|
||||
foreach (var thumbprint in RemoveThumbprints)
|
||||
{
|
||||
List<X509Certificate2> certificates;
|
||||
if (existingThumbprints.TryGetValue(thumbprint, out certificates) && !addedThumbprints.Contains(thumbprint))
|
||||
if (existingThumbprints.TryGetValue(thumbprint, out var certificates) && !addedThumbprints.Contains(thumbprint))
|
||||
{
|
||||
foreach (var certificate in certificates)
|
||||
{
|
||||
|
||||
@@ -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,240 @@ 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.ApplyMobileDeviceManagementInformation();
|
||||
|
||||
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 +285,42 @@ namespace Disco.Client.Interop
|
||||
{
|
||||
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber");
|
||||
if (!string.IsNullOrWhiteSpace(serialNumber))
|
||||
{
|
||||
DeviceHardware.SerialNumber = serialNumber.Trim();
|
||||
}
|
||||
deviceHardware.SerialNumber = serialNumber.Trim();
|
||||
|
||||
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
|
||||
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
|
||||
if (deviceHardware.Manufacturer == null && !string.IsNullOrWhiteSpace(manufacturer))
|
||||
deviceHardware.Manufacturer = manufacturer.Trim();
|
||||
|
||||
ErrorReporting.DeviceIdentifier = deviceHardware.SerialNumber;
|
||||
|
||||
var biosVersion = (string[])mItem.GetPropertyValue("BIOSVersion");
|
||||
var releaseDate = default(DateTime?);
|
||||
var releaseDateString = (string)mItem.GetPropertyValue("ReleaseDate");
|
||||
if (releaseDateString != null && releaseDateString.Length == 25 && int.TryParse(releaseDateString.Substring(22), out var offsetMinutes))
|
||||
{
|
||||
releaseDateString = $"{releaseDateString.Substring(0, 22)}{offsetMinutes / 60:00}:{Math.Abs(offsetMinutes % 60):00}";
|
||||
if (DateTime.TryParseExact(releaseDateString, "yyyyMMddHHmmss.ffffffzzz", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var releaseDateResult))
|
||||
releaseDate = releaseDateResult;
|
||||
}
|
||||
var sMBIOSBIOSVersion = (string)mItem.GetPropertyValue("SMBIOSBIOSVersion");
|
||||
var sMBIOSMajorVersion = (ushort?)mItem.GetPropertyValue("SMBIOSMajorVersion");
|
||||
var sMBIOSMinorVersion = (ushort?)mItem.GetPropertyValue("SMBIOSMinorVersion");
|
||||
var systemBiosMajorVersion = (byte?)mItem.GetPropertyValue("SystemBiosMajorVersion");
|
||||
var systemBiosMinorVersion = (byte?)mItem.GetPropertyValue("SystemBiosMinorVersion");
|
||||
|
||||
var bios = new Bios()
|
||||
{
|
||||
BIOSVersion = biosVersion,
|
||||
Manufacturer = manufacturer,
|
||||
ReleaseDate = releaseDate,
|
||||
SerialNumber = serialNumber,
|
||||
SMBIOSBIOSVersion = sMBIOSBIOSVersion,
|
||||
SMBIOSMajorVersion = sMBIOSMajorVersion,
|
||||
SMBIOSMinorVersion = sMBIOSMinorVersion,
|
||||
SystemBiosMajorVersion = systemBiosMajorVersion,
|
||||
SystemBiosMinorVersion = systemBiosMinorVersion,
|
||||
};
|
||||
deviceHardware.Bios = new List<Bios>() { bios };
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,15 +332,15 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve BIOS information from WMI", ex);
|
||||
throw new Exception("Disco ICT Client was unable to retrieve BIOS information from WMI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplySystemInformation(this DeviceHardware DeviceHardware)
|
||||
private static void ApplySystemInformation(this DeviceHardware deviceHardware)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var mSearcher = new ManagementObjectSearcher("SELECT Manufacturer, Model, PartOfDomain, PCSystemType, Domain FROM Win32_ComputerSystem"))
|
||||
using (var mSearcher = new ManagementObjectSearcher("SELECT ChassisSKUNumber, CurrentTimeZone, Description, Manufacturer, Model, OEMStringArray, PCSystemType, PrimaryOwnerContact, PrimaryOwnerName, Roles, SystemSKUNumber, SystemType FROM Win32_ComputerSystem"))
|
||||
{
|
||||
using (var mResults = mSearcher.Get())
|
||||
{
|
||||
@@ -95,17 +350,40 @@ namespace Disco.Client.Interop
|
||||
{
|
||||
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
|
||||
if (!string.IsNullOrWhiteSpace(manufacturer))
|
||||
{
|
||||
DeviceHardware.Manufacturer = manufacturer.Trim();
|
||||
}
|
||||
deviceHardware.Manufacturer = manufacturer.Trim();
|
||||
|
||||
var model = (string)mItem.GetPropertyValue("Model");
|
||||
if (!string.IsNullOrWhiteSpace(model))
|
||||
{
|
||||
DeviceHardware.Model = model.ToString();
|
||||
}
|
||||
deviceHardware.Model = model;
|
||||
|
||||
DeviceHardware.ModelType = ((PCSystemTypes)mItem.GetPropertyValue("PCSystemType")).Description();
|
||||
deviceHardware.ModelType = ((PCSystemTypes)mItem.GetPropertyValue("PCSystemType")).Description();
|
||||
|
||||
var chassisSKUNumber = (string)mItem.GetPropertyValue("ChassisSKUNumber");
|
||||
var currentTimeZone = (short?)mItem.GetPropertyValue("CurrentTimeZone");
|
||||
var description = (string)mItem.GetPropertyValue("Description");
|
||||
var oemStringArray = (string[])mItem.GetPropertyValue("OEMStringArray");
|
||||
var pcSystemType = ((PCSystemTypes)mItem.GetPropertyValue("PCSystemType")).ToString();
|
||||
var primaryOwnerContact = (string)mItem.GetPropertyValue("PrimaryOwnerContact");
|
||||
var primaryOwnerName = (string)mItem.GetPropertyValue("PrimaryOwnerName");
|
||||
var roles = (string[])mItem.GetPropertyValue("Roles");
|
||||
var systemSKUNumber = (string)mItem.GetPropertyValue("SystemSKUNumber");
|
||||
var systemType = (string)mItem.GetPropertyValue("SystemType");
|
||||
|
||||
var computerSystem = new ComputerSystem()
|
||||
{
|
||||
ChassisSKUNumber = chassisSKUNumber,
|
||||
CurrentTimeZone = currentTimeZone,
|
||||
Description = description,
|
||||
OEMStringArray = oemStringArray,
|
||||
PCSystemType = pcSystemType,
|
||||
PrimaryOwnerContact = primaryOwnerContact,
|
||||
PrimaryOwnerName = primaryOwnerName,
|
||||
Roles = roles,
|
||||
SystemSKUNumber = systemSKUNumber,
|
||||
SystemType = systemType,
|
||||
};
|
||||
|
||||
deviceHardware.ComputerSystem = new List<ComputerSystem>() { computerSystem };
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -117,11 +395,11 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve ComputerSystem information from WMI", ex);
|
||||
throw new Exception("Disco ICT Client was unable to retrieve ComputerSystem information from WMI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ApplySystemInformation(this Enrol Enrol)
|
||||
public static void ApplySystemInformation(this Enrol enrol)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -133,11 +411,11 @@ namespace Disco.Client.Interop
|
||||
{
|
||||
if (mItem != null)
|
||||
{
|
||||
Enrol.IsPartOfDomain = (bool)mItem.GetPropertyValue("PartOfDomain");
|
||||
|
||||
if (Enrol.IsPartOfDomain)
|
||||
enrol.IsPartOfDomain = (bool)mItem.GetPropertyValue("PartOfDomain");
|
||||
|
||||
if (enrol.IsPartOfDomain)
|
||||
{
|
||||
Enrol.DNSDomainName = (string)mItem.GetPropertyValue("Domain");
|
||||
enrol.DNSDomainName = (string)mItem.GetPropertyValue("Domain");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -150,52 +428,88 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve ComputerSystem information from WMI", ex);
|
||||
throw new Exception("Disco ICT Client was unable to retrieve ComputerSystem information from WMI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyBaseBoardInformation(this DeviceHardware DeviceHardware)
|
||||
private static void ApplyBaseBoardInformation(this DeviceHardware deviceHardware)
|
||||
{
|
||||
// Added 2012-11-22 G# - Lenovo IdeaPad Serial SHIM
|
||||
// http://www.discoict.com.au/forum/feature-requests/2012/11/serial-number-detection-on-ideapads.aspx
|
||||
if (string.IsNullOrWhiteSpace(DeviceHardware.SerialNumber) ||
|
||||
(DeviceHardware.Manufacturer.Equals("LENOVO", StringComparison.OrdinalIgnoreCase) &&
|
||||
(DeviceHardware.Model.Equals("S10-3", StringComparison.OrdinalIgnoreCase) // S10-3
|
||||
|| DeviceHardware.Model.Equals("2957", StringComparison.OrdinalIgnoreCase)))) // S10-2
|
||||
try
|
||||
{
|
||||
try
|
||||
using (var mSearcher = new ManagementObjectSearcher("SELECT ConfigOptions, Manufacturer, Model, PartNumber, Product, SerialNumber, SKU, Version FROM Win32_BaseBoard"))
|
||||
{
|
||||
using (var mSearcher = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BaseBoard"))
|
||||
using (var mResults = mSearcher.Get())
|
||||
{
|
||||
using (var mResults = mSearcher.Get())
|
||||
using (var mItem = mResults.Cast<ManagementObject>().FirstOrDefault())
|
||||
{
|
||||
using (var mItem = mResults.Cast<ManagementObject>().FirstOrDefault())
|
||||
if (mItem != null)
|
||||
{
|
||||
if (mItem != null)
|
||||
// Apply Manufacturer/Model information only if not previously found in Win32_ComputerSystem
|
||||
var manufacturer = (string)mItem.GetPropertyValue("Manufacturer");
|
||||
if (deviceHardware.Manufacturer == null && !string.IsNullOrWhiteSpace(manufacturer))
|
||||
{
|
||||
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber");
|
||||
if (!string.IsNullOrWhiteSpace(serialNumber))
|
||||
{
|
||||
DeviceHardware.SerialNumber = serialNumber.Trim();
|
||||
ErrorReporting.DeviceIdentifier = DeviceHardware.SerialNumber;
|
||||
}
|
||||
deviceHardware.Manufacturer = manufacturer.Trim();
|
||||
}
|
||||
else
|
||||
|
||||
var model = (string)mItem.GetPropertyValue("Model");
|
||||
if (deviceHardware.Model == null && !string.IsNullOrWhiteSpace(model))
|
||||
{
|
||||
throw new Exception("No Win32_BaseBoard was found");
|
||||
deviceHardware.Model = model;
|
||||
}
|
||||
|
||||
var product = (string)mItem.GetPropertyValue("Product");
|
||||
if (deviceHardware.Model == null && !string.IsNullOrWhiteSpace(product))
|
||||
{
|
||||
deviceHardware.Model = product;
|
||||
}
|
||||
|
||||
// Added 2012-11-22 G# - Lenovo IdeaPad Serial SHIM
|
||||
// http://www.discoict.com.au/forum/feature-requests/2012/11/serial-number-detection-on-ideapads.aspx
|
||||
var serialNumber = (string)mItem.GetPropertyValue("SerialNumber");
|
||||
if (!string.IsNullOrWhiteSpace(serialNumber) &&
|
||||
(deviceHardware.SerialNumber == null ||
|
||||
((deviceHardware.Manufacturer?.Equals("LENOVO", StringComparison.OrdinalIgnoreCase) ?? false) &&
|
||||
((deviceHardware.Model?.Equals("S10-3", StringComparison.OrdinalIgnoreCase) ?? false) // S10-3
|
||||
|| (deviceHardware.Model?.Equals("2957", StringComparison.OrdinalIgnoreCase) ?? false)))))
|
||||
{
|
||||
deviceHardware.SerialNumber = serialNumber.Trim();
|
||||
ErrorReporting.DeviceIdentifier = deviceHardware.SerialNumber;
|
||||
}
|
||||
|
||||
var configOptions = (string[])mItem.GetPropertyValue("ConfigOptions");
|
||||
var partNumber = (string)mItem.GetPropertyValue("PartNumber");
|
||||
var sku = (string)mItem.GetPropertyValue("SKU");
|
||||
var version = (string)mItem.GetPropertyValue("Version");
|
||||
|
||||
var baseBoard = new BaseBoard()
|
||||
{
|
||||
ConfigOptions = configOptions,
|
||||
Manufacturer = manufacturer,
|
||||
Model = model,
|
||||
PartNumber = partNumber,
|
||||
Product = product,
|
||||
SerialNumber = serialNumber,
|
||||
SKU = sku,
|
||||
Version = version,
|
||||
};
|
||||
|
||||
deviceHardware.BasebBoard = new List<BaseBoard>() { baseBoard };
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("No Win32_BaseBoard was found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve BaseBoard information from WMI", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco ICT Client was unable to retrieve BaseBoard information from WMI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplySystemProductInformation(this DeviceHardware DeviceHardware)
|
||||
private static void ApplySystemProductInformation(this DeviceHardware deviceHardware)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -207,19 +521,30 @@ 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))
|
||||
{
|
||||
if (Guid.TryParse(deviceHardware.UUID, out var uuidGuid) && uuidGuid != Guid.Empty)
|
||||
{
|
||||
deviceHardware.SerialNumber = $"UUID{uuidGuid:N}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -231,10 +556,22 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve ComputerSystemProduct information from WMI", ex);
|
||||
throw new Exception("Disco ICT Client was unable to retrieve ComputerSystemProduct information from WMI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyMobileDeviceManagementInformation(this DeviceHardware deviceHardware)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var wmiObject = new ManagementObject(@"\\.\ROOT\CIMV2\mdm\dmmap:MDM_DevDetail_Ext01.InstanceID=""Ext"",ParentID=""./DevDetail"""))
|
||||
{
|
||||
deviceHardware.MdmHardwareData = (string)wmiObject.GetPropertyValue("DeviceHardwareData");
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
private static string Description(this PCSystemTypes type)
|
||||
{
|
||||
switch (type)
|
||||
@@ -273,5 +610,93 @@ namespace Disco.Client.Interop
|
||||
PerformanceServer,
|
||||
Maximum
|
||||
}
|
||||
|
||||
private enum ProcessorArchitectures : ushort
|
||||
{
|
||||
x86 = 0,
|
||||
MIPS = 1,
|
||||
Alpha = 2,
|
||||
PowerPC = 3,
|
||||
ia64 = 6,
|
||||
x64 = 9,
|
||||
}
|
||||
|
||||
private enum DiskLogicalDriveTypes : uint
|
||||
{
|
||||
Unknown = 0,
|
||||
NoRootDirectory,
|
||||
Removable,
|
||||
Fixed,
|
||||
Remote,
|
||||
CDRom,
|
||||
RAMDisk,
|
||||
}
|
||||
|
||||
private enum DiskLogicalMediaTypes : uint
|
||||
{
|
||||
Unknown = 0,
|
||||
F5_1Pt2_512,
|
||||
F3_1Pt44_512,
|
||||
F3_2Pt88_512,
|
||||
F3_20Pt8_512,
|
||||
F3_720_512,
|
||||
F5_360_512,
|
||||
F5_320_512,
|
||||
F5_320_1024,
|
||||
F5_180_512,
|
||||
F5_160_512,
|
||||
RemovableMedia,
|
||||
FixedMedia,
|
||||
F3_120M_512,
|
||||
F3_640_512,
|
||||
F5_640_512,
|
||||
F5_720_512,
|
||||
F3_1Pt2_512,
|
||||
F3_1Pt23_1024,
|
||||
F5_1Pt23_1024,
|
||||
F3_128Mb_512,
|
||||
F3_230Mb_512,
|
||||
F8_256_128,
|
||||
F3_200Mb_512,
|
||||
F3_240M_512,
|
||||
F3_32M_512,
|
||||
}
|
||||
|
||||
private enum BatteryAvailability : ushort
|
||||
{
|
||||
Other = 1,
|
||||
Unknown = 2,
|
||||
RunningFullPower = 3,
|
||||
Warning = 4,
|
||||
InTest = 5,
|
||||
NotApplicable = 6,
|
||||
PowerOff = 7,
|
||||
OffLine = 8,
|
||||
OffDuty = 9,
|
||||
Degraded = 10,
|
||||
NotInstalled = 11,
|
||||
InstallError = 12,
|
||||
PowerSaveUnknown = 13,
|
||||
PowerSaveLowPowerMode = 14,
|
||||
PowerSaveStandby = 15,
|
||||
PowerCycle = 16,
|
||||
PowerSaveWarning = 17,
|
||||
Paused = 18,
|
||||
NotReady = 19,
|
||||
NotConfigured = 20,
|
||||
Quiesced = 21,
|
||||
}
|
||||
|
||||
private enum BatteryChemistry : ushort
|
||||
{
|
||||
Other = 1,
|
||||
Unknown = 2,
|
||||
LeadAcid = 3,
|
||||
NickelCadmium = 4,
|
||||
NickelMetalHydride = 5,
|
||||
LithiumIon = 6,
|
||||
ZincAir = 7,
|
||||
LithiumPolymer = 8,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Disco.Client.Interop.Native
|
||||
namespace Disco.Client.Interop.Native
|
||||
{
|
||||
public enum NetworkConnectionStatuses : ushort
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Disco.Client.Interop.Native
|
||||
/// The number of wireless profile entries in the ProfileInfo member.
|
||||
/// </summary>
|
||||
public uint dwNumberOfItems;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The index of the current item. The index of the first item is 0. The dwIndex member must be less than the dwNumberOfItems member.
|
||||
/// This member is not used by the wireless service. Applications can use this member when processing individual profiles in the
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Disco.Client.Interop
|
||||
|
||||
return adapters;
|
||||
}
|
||||
|
||||
|
||||
private static List<NetworkAdapter> GetWmiNetworkAdapters()
|
||||
{
|
||||
try
|
||||
@@ -68,7 +68,7 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve NetworkAdapter information from WMI", ex);
|
||||
throw new Exception("Disco ICT Client was unable to retrieve NetworkAdapter information from WMI", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,13 @@ namespace Disco.Client.Interop
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr wlanHandle;
|
||||
uint wlanServiceVersion;
|
||||
|
||||
if (WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out wlanServiceVersion, out wlanHandle) == WlanApi.ERROR_SUCCESS)
|
||||
if (WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out var wlanServiceVersion, out var wlanHandle) == WlanApi.ERROR_SUCCESS)
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr wlanInterfacesPtr;
|
||||
|
||||
if (WlanApi.WlanEnumInterfaces(wlanHandle, IntPtr.Zero, out wlanInterfacesPtr) == WlanApi.ERROR_SUCCESS)
|
||||
if (WlanApi.WlanEnumInterfaces(wlanHandle, IntPtr.Zero, out var wlanInterfacesPtr) == WlanApi.ERROR_SUCCESS)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -61,7 +58,7 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve Wireless NetworkAdapter information from WlanApi", ex);
|
||||
throw new Exception("Disco ICT Client was unable to retrieve Wireless NetworkAdapter information from WlanApi", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +66,10 @@ namespace Disco.Client.Interop
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr wlanHandle;
|
||||
uint wlanServiceVersion;
|
||||
uint interopResult;
|
||||
|
||||
// Connect to wireless service
|
||||
interopResult = WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out wlanServiceVersion, out wlanHandle);
|
||||
interopResult = WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out var wlanServiceVersion, out var wlanHandle);
|
||||
if (interopResult == WlanApi.ERROR_SERVICE_NOT_ACTIVE)
|
||||
{
|
||||
// Indicates the Wlan service has not been started on the client
|
||||
@@ -102,17 +97,16 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve Wireless Profiles from WlanApi", ex);
|
||||
throw new Exception("Disco ICT Client was unable to retrieve Wireless Profiles from WlanApi", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<WirelessProfile> GetWirelessProfiles(IntPtr wlanHandle)
|
||||
{
|
||||
uint interopResult;
|
||||
IntPtr wlanInterfacesPtr;
|
||||
|
||||
// Enumerate wireless interfaces
|
||||
interopResult = WlanApi.WlanEnumInterfaces(wlanHandle, IntPtr.Zero, out wlanInterfacesPtr);
|
||||
interopResult = WlanApi.WlanEnumInterfaces(wlanHandle, IntPtr.Zero, out var wlanInterfacesPtr);
|
||||
if (interopResult != WlanApi.ERROR_SUCCESS)
|
||||
{
|
||||
throw new Exception($"Unable to list interfaces with the local wireless service. WlanEnumInterfaces returned: {interopResult}");
|
||||
@@ -124,9 +118,8 @@ namespace Disco.Client.Interop
|
||||
|
||||
foreach (var wlanInterface in wlanInterfaces.InterfaceInfo)
|
||||
{
|
||||
IntPtr wlanProfilesPtr;
|
||||
// Enumerate wireless profiles for interface
|
||||
interopResult = WlanApi.WlanGetProfileList(wlanHandle, wlanInterface.InterfaceGuid, IntPtr.Zero, out wlanProfilesPtr);
|
||||
interopResult = WlanApi.WlanGetProfileList(wlanHandle, wlanInterface.InterfaceGuid, IntPtr.Zero, out var wlanProfilesPtr);
|
||||
if (interopResult != WlanApi.ERROR_SUCCESS)
|
||||
{
|
||||
throw new Exception($"Unable to list wireless profiles for the {wlanInterface.InterfaceGuid} interface with the local wireless service. WlanGetProfileList returned: {interopResult}");
|
||||
@@ -165,12 +158,10 @@ namespace Disco.Client.Interop
|
||||
|
||||
try
|
||||
{
|
||||
IntPtr wlanHandle;
|
||||
uint wlanServiceVersion;
|
||||
uint interopResult;
|
||||
|
||||
// Connect to wireless service
|
||||
interopResult = WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out wlanServiceVersion, out wlanHandle);
|
||||
interopResult = WlanApi.WlanOpenHandle(WlanApi.WLAN_API_VERSION_2_0, IntPtr.Zero, out var wlanServiceVersion, out var wlanHandle);
|
||||
if (interopResult == WlanApi.ERROR_SERVICE_NOT_ACTIVE)
|
||||
{
|
||||
// Indicates the Wlan service has not been started on the client
|
||||
@@ -243,9 +234,8 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
else
|
||||
{
|
||||
uint pdwReasonCode;
|
||||
Presentation.UpdateStatus("Enrolling Device", $"Configuring Wireless Profiles\r\nAdding Wireless Profile '{addProfile.Name}' on '{adapter.NetConnectionID}'", true, -1, 1000);
|
||||
interopResult = WlanApi.WlanSetProfile(wlanHandle, adapter.ConnectionIdentifier, 0, addProfile.ProfileXml, null, true, IntPtr.Zero, out pdwReasonCode);
|
||||
interopResult = WlanApi.WlanSetProfile(wlanHandle, adapter.ConnectionIdentifier, 0, addProfile.ProfileXml, null, true, IntPtr.Zero, out var pdwReasonCode);
|
||||
|
||||
if (interopResult != WlanApi.ERROR_SUCCESS)
|
||||
{
|
||||
@@ -285,11 +275,8 @@ namespace Disco.Client.Interop
|
||||
else
|
||||
{
|
||||
// Load profile
|
||||
IntPtr pstrProfileXml;
|
||||
uint pdwFlags;
|
||||
IntPtr pdwGrantAccess;
|
||||
|
||||
interopResult = WlanApi.WlanGetProfile(wlanHandle, adapter.ConnectionIdentifier, profileName, IntPtr.Zero, out pstrProfileXml, out pdwFlags, out pdwGrantAccess);
|
||||
interopResult = WlanApi.WlanGetProfile(wlanHandle, adapter.ConnectionIdentifier, profileName, IntPtr.Zero, out var pstrProfileXml, out var pdwFlags, out var pdwGrantAccess);
|
||||
|
||||
if (interopResult == WlanApi.ERROR_SUCCESS)
|
||||
{
|
||||
@@ -312,10 +299,9 @@ namespace Disco.Client.Interop
|
||||
if (!XNode.DeepEquals(originalProfileXml, transformedProfileXml))
|
||||
{
|
||||
// Set Profile
|
||||
uint pdwReasonCode;
|
||||
Presentation.UpdateStatus("Enrolling Device", $"Configuring Wireless Profiles\r\nModifying Wireless Profile '{profileName}' on '{adapter.NetConnectionID}'", true, -1, 1000);
|
||||
transformProfileXml = transformedProfileXml.ToString(SaveOptions.None);
|
||||
interopResult = WlanApi.WlanSetProfile(wlanHandle, adapter.ConnectionIdentifier, 0, transformProfileXml, null, true, IntPtr.Zero, out pdwReasonCode);
|
||||
interopResult = WlanApi.WlanSetProfile(wlanHandle, adapter.ConnectionIdentifier, 0, transformProfileXml, null, true, IntPtr.Zero, out var pdwReasonCode);
|
||||
|
||||
if (interopResult != WlanApi.ERROR_SUCCESS)
|
||||
{
|
||||
@@ -356,7 +342,7 @@ namespace Disco.Client.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to apply Wireless Profile Changes using WlanApi", ex);
|
||||
throw new Exception("Disco ICT Client was unable to apply Wireless Profile Changes using WlanApi", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Disco.Client.Extensions;
|
||||
using Disco.Client.Interop;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Disco.Client.Extensions;
|
||||
using Disco.Client.Interop;
|
||||
|
||||
namespace Disco.Client
|
||||
{
|
||||
@@ -22,13 +20,13 @@ namespace Disco.Client
|
||||
}
|
||||
public static void UpdateStatus(string SubHeading, string Message, bool ShowProgress, int Progress, int TryDelay)
|
||||
{
|
||||
Presentation.UpdateStatus(SubHeading, Message, ShowProgress, Progress);
|
||||
UpdateStatus(SubHeading, Message, ShowProgress, Progress);
|
||||
if (TryDelay > 0)
|
||||
Presentation.TryDelay(TryDelay);
|
||||
}
|
||||
public static void UpdateStatus(string SubHeading, string Message, bool ShowProgress, int Progress)
|
||||
{
|
||||
Console.WriteLine("#{0},{1},{2},{3}", SubHeading.EscapeMessage(), Message.EscapeMessage(), ShowProgress.ToString(), Progress.ToString());
|
||||
Console.WriteLine($"#{SubHeading.EscapeMessage()},{Message.EscapeMessage()},{ShowProgress.ToString()},{Progress.ToString()}");
|
||||
}
|
||||
public static void TryDelay(int Milliseconds)
|
||||
{
|
||||
@@ -92,7 +90,7 @@ namespace Disco.Client
|
||||
|
||||
public static void RegisterBootstrapperPostActions(ShutdownActions ShutdownAction, bool Uninstall)
|
||||
{
|
||||
Console.WriteLine("!{0},{1}", Enum.GetName(typeof(ShutdownActions), ShutdownAction), Uninstall ? "UninstallBootstrapper" : "DontUninstallBootstrapper");
|
||||
Console.WriteLine($"!{Enum.GetName(typeof(ShutdownActions), ShutdownAction)},{(Uninstall ? "UninstallBootstrapper" : "DontUninstallBootstrapper")}");
|
||||
}
|
||||
public enum ShutdownActions
|
||||
{
|
||||
|
||||
+35
-15
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Disco.Client.Extensions;
|
||||
using Disco.Models.ClientServices;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Disco.Models.ClientServices;
|
||||
using Disco.Client.Extensions;
|
||||
|
||||
namespace Disco.Client
|
||||
{
|
||||
@@ -38,14 +35,14 @@ namespace Disco.Client
|
||||
Presentation.WriteBanner();
|
||||
|
||||
// WhoAmI Phase
|
||||
keepProcessing = Program.WhoAmI();
|
||||
keepProcessing = WhoAmI();
|
||||
|
||||
// Enrol Phase
|
||||
if (keepProcessing)
|
||||
keepProcessing = Program.Enrol();
|
||||
keepProcessing = Enrol();
|
||||
|
||||
// End conversation with Bootstrapper
|
||||
Presentation.WriteFooter(Program.RebootRequired, Program.AllowUninstall, !keepProcessing);
|
||||
Presentation.WriteFooter(RebootRequired, AllowUninstall, !keepProcessing);
|
||||
}
|
||||
|
||||
public static void SetupEnvironment()
|
||||
@@ -126,13 +123,36 @@ namespace Disco.Client
|
||||
request = new Enrol();
|
||||
request.Build();
|
||||
|
||||
// Send Request
|
||||
Presentation.UpdateStatus("Enrolling Device", "Sending the enrolment request to the server.", true, -1);
|
||||
response = request.Post(Program.IsAuthenticated);
|
||||
var startTime = DateTimeOffset.Now;
|
||||
do
|
||||
{
|
||||
// Send Request
|
||||
Presentation.UpdateStatus("Enrolling Device", "Sending the enrolment request to the server.", true, -1);
|
||||
response = request.Post(IsAuthenticated);
|
||||
|
||||
// Process Response
|
||||
Presentation.UpdateStatus("Enrolling Device", "Processing the enrolment response from the server.", true, -1);
|
||||
response.Process();
|
||||
// Process Response
|
||||
Presentation.UpdateStatus("Enrolling Device", "Processing the enrolment response from the server.", true, -1);
|
||||
response.Process();
|
||||
|
||||
if (response.IsPending)
|
||||
{
|
||||
request.PendingSessionId = response.SessionId;
|
||||
request.PendingAuthorization = response.PendingAuthorization;
|
||||
|
||||
// Session Pending
|
||||
var totalSeconds = (response.PendingTimeout - startTime).TotalSeconds;
|
||||
var secondsConsumed = (DateTimeOffset.Now - startTime).TotalSeconds;
|
||||
var progress = (int)((secondsConsumed / totalSeconds) * 100);
|
||||
|
||||
Presentation.UpdateStatus($"Pending Device Enrolment Approval: {response.PendingIdentifier}", $"Waiting for enrolment session '{response.PendingIdentifier}' to be approved.{Environment.NewLine}Reason: {response.PendingReason}", true, progress);
|
||||
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Session Complete
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
|
||||
// Complete
|
||||
return true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyFileVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyVersion("2.5.25262.0000")]
|
||||
[assembly: AssemblyFileVersion("2.5.25262.0000")]
|
||||
@@ -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>
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Disco.ClientBootstrapper
|
||||
{
|
||||
@@ -20,25 +20,25 @@ 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)
|
||||
{
|
||||
this.statusUI = StatusUI;
|
||||
this.mLoopCompleteCallback = Callback;
|
||||
this.errorMessage = new StringBuilder();
|
||||
statusUI = StatusUI;
|
||||
mLoopCompleteCallback = Callback;
|
||||
errorMessage = new StringBuilder();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
this.LoopThread = new Thread(new ThreadStart(loopHost));
|
||||
this.LoopThread.Start();
|
||||
LoopThread = new Thread(new ThreadStart(loopHost));
|
||||
LoopThread.Start();
|
||||
}
|
||||
|
||||
private void loopHost()
|
||||
@@ -85,12 +85,12 @@ namespace Disco.ClientBootstrapper
|
||||
|
||||
// Check for Network Connectivity
|
||||
statusUI.UpdateStatus(null, "Detecting Network", "Checking network connectivity, Please wait...", true, -1);
|
||||
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
|
||||
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
|
||||
{
|
||||
statusUI.UpdateStatus(null, "Detecting Network", "No network connectivity detected, Diagnosing...", true, -1);
|
||||
statusUI_WriteAdapterInfo();
|
||||
|
||||
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
|
||||
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
|
||||
{
|
||||
// Check for Wireless
|
||||
var hasWireless = (Interop.NetworkInterop.NetworkAdapters.Count(na => na.IsWireless) > 0);
|
||||
@@ -105,17 +105,17 @@ namespace Disco.ClientBootstrapper
|
||||
statusUI_WriteAdapterInfo();
|
||||
statusUI.UpdateStatus(null, null, null, true, i);
|
||||
Program.SleepThread(500, false);
|
||||
if (Interop.NetworkInterop.PingDisco(DiscoServerName))
|
||||
if (Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
|
||||
break;
|
||||
}
|
||||
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
|
||||
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
|
||||
{
|
||||
statusUI.UpdateStatus(null, "Wireless Network Failed", "Unable to connect to the wireless network, please connect the network cable...", false);
|
||||
Program.SleepThread(3000, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
|
||||
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
|
||||
{
|
||||
// Instruct user to connect network cable
|
||||
statusUI.UpdateStatus(null, "Please connect the network cable", null);
|
||||
@@ -124,18 +124,18 @@ namespace Disco.ClientBootstrapper
|
||||
statusUI_WriteAdapterInfo();
|
||||
statusUI.UpdateStatus(null, null, null, true, i);
|
||||
Program.SleepThread(500, false);
|
||||
if (Interop.NetworkInterop.PingDisco(DiscoServerName))
|
||||
if (Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Interop.NetworkInterop.PingDisco(DiscoServerName))
|
||||
}
|
||||
|
||||
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
|
||||
{
|
||||
// Client Failed
|
||||
if (this.mLoopCompleteCallback != null)
|
||||
if (mLoopCompleteCallback != null)
|
||||
{
|
||||
this.mLoopCompleteCallback.BeginInvoke(null, null);
|
||||
mLoopCompleteCallback.BeginInvoke(null, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -197,15 +197,15 @@ namespace Disco.ClientBootstrapper
|
||||
Interop.CertificateInterop.RemoveTempCerts();
|
||||
|
||||
// Pause if Error
|
||||
if (this.errorMessage.Length > 0)
|
||||
if (errorMessage.Length > 0)
|
||||
{
|
||||
Program.SleepThread(10000, true);
|
||||
}
|
||||
|
||||
// End Of Loop
|
||||
if (this.mLoopCompleteCallback != null)
|
||||
if (mLoopCompleteCallback != null)
|
||||
{
|
||||
this.mLoopCompleteCallback.BeginInvoke(null, null);
|
||||
mLoopCompleteCallback.BeginInvoke(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,11 +217,11 @@ namespace Disco.ClientBootstrapper
|
||||
{
|
||||
if (na.IsWireless)
|
||||
{
|
||||
info.AppendLine(string.Format("{0}: {1}", na.NetConnectionID, na.WirelessConnectionStatusMeaning(na.WirelessConnectionStatus)));
|
||||
info.AppendLine($"{na.NetConnectionID}: {na.WirelessConnectionStatusMeaning(na.WirelessConnectionStatus)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
info.AppendLine(string.Format("{0}: {1}", na.NetConnectionID, na.ConnectionStatusMeaning(na.ConnectionStatus)));
|
||||
info.AppendLine($"{na.NetConnectionID}: {na.ConnectionStatusMeaning(na.ConnectionStatus)}");
|
||||
}
|
||||
}
|
||||
statusUI.UpdateStatus(null, null, info.ToString());
|
||||
@@ -232,7 +232,7 @@ namespace Disco.ClientBootstrapper
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(e.Data))
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(string.Format("OUTPUT: {0}", e.Data));
|
||||
Debug.WriteLine($"OUTPUT: {e.Data}");
|
||||
var data = e.Data.Substring(1).Split(new char[] { ',' });
|
||||
switch (e.Data[0])
|
||||
{
|
||||
|
||||
@@ -8,4 +8,4 @@ BootstrapperLocation = Mid(WScript.ScriptFullName, 1, InStrRev(WScript.ScriptFul
|
||||
|
||||
Call objShell.Run("""" & BootstrapperLocation & """ /Install", , True)
|
||||
|
||||
WScript.Echo "Disco Client Bootstrapper Installed"
|
||||
WScript.Echo "Disco ICT Client Bootstrapper Installed"
|
||||
@@ -10,8 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Disco.ClientBootstrapper</RootNamespace>
|
||||
<AssemblyName>Disco.ClientBootstrapper</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@
|
||||
this.labelVersion.Name = "labelVersion";
|
||||
this.labelVersion.Size = new System.Drawing.Size(167, 20);
|
||||
this.labelVersion.TabIndex = 0;
|
||||
this.labelVersion.Text = "Disco Bootstrapper v";
|
||||
this.labelVersion.Text = "Disco ICT Bootstrapper v";
|
||||
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// FormStatus
|
||||
@@ -106,7 +106,7 @@
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Disco - Client Bootstrapper";
|
||||
this.Text = "Disco ICT - Client Bootstrapper";
|
||||
this.TopMost = true;
|
||||
this.TransparencyKey = System.Drawing.Color.Magenta;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Disco.ClientBootstrapper
|
||||
@@ -12,7 +6,7 @@ namespace Disco.ClientBootstrapper
|
||||
public partial class FormStatus : Form, IStatus
|
||||
{
|
||||
|
||||
private delegate void dUpdateStatus(string Heading, string SubHeading, string Message, Nullable<bool> ShowProgress, Nullable<int> Progress);
|
||||
private delegate void dUpdateStatus(string Heading, string SubHeading, string Message, bool? ShowProgress, int? Progress);
|
||||
private dUpdateStatus mUpdateStatus;
|
||||
|
||||
public FormStatus()
|
||||
@@ -20,7 +14,7 @@ namespace Disco.ClientBootstrapper
|
||||
InitializeComponent();
|
||||
|
||||
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
this.labelVersion.Text = string.Format("v{0}", version.ToString(3));
|
||||
this.labelVersion.Text = $"v{version.ToString(3)}";
|
||||
|
||||
this.FormClosed += new FormClosedEventHandler(FormStatus_FormClosed);
|
||||
|
||||
@@ -34,7 +28,7 @@ namespace Disco.ClientBootstrapper
|
||||
Program.ExitApplication();
|
||||
}
|
||||
|
||||
public void UpdateStatus(string Heading, string SubHeading, string Message, Nullable<bool> ShowProgress = null, Nullable<int> Progress = null)
|
||||
public void UpdateStatus(string Heading, string SubHeading, string Message, bool? ShowProgress = null, int? Progress = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -42,7 +36,7 @@ namespace Disco.ClientBootstrapper
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
private void UpdateStatusDo(string Heading, string SubHeading, string Message, Nullable<bool> ShowProgress, Nullable<int> Progress)
|
||||
private void UpdateStatusDo(string Heading, string SubHeading, string Message, bool? ShowProgress, int? Progress)
|
||||
{
|
||||
if (Heading != null)
|
||||
if (this.labelHeading.Text != Heading)
|
||||
@@ -61,7 +55,7 @@ namespace Disco.ClientBootstrapper
|
||||
this.progressBar.Visible = true;
|
||||
if (Progress.HasValue)
|
||||
{
|
||||
if (Progress.Value > 0)
|
||||
if (Progress.Value >= 0)
|
||||
{
|
||||
this.progressBar.Value = Math.Min(Progress.Value, 100);
|
||||
this.progressBar.Style = ProgressBarStyle.Continuous;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Disco.ClientBootstrapper
|
||||
namespace Disco.ClientBootstrapper
|
||||
{
|
||||
interface IStatus
|
||||
{
|
||||
void UpdateStatus(string Heading, string SubHeading, string Message, Nullable<bool> ShowProgress = null, Nullable<int> Progress = null);
|
||||
void UpdateStatus(string Heading, string SubHeading, string Message, bool? ShowProgress = null, int? Progress = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace Disco.ClientBootstrapper
|
||||
|
||||
public void Start(CompleteCallback Callback)
|
||||
{
|
||||
this.mCompleteCallback = Callback;
|
||||
this.LoopThread = new Thread(new ThreadStart(loopHost));
|
||||
this.LoopThread.Start();
|
||||
mCompleteCallback = Callback;
|
||||
LoopThread = new Thread(new ThreadStart(loopHost));
|
||||
LoopThread.Start();
|
||||
}
|
||||
private void loopHost()
|
||||
{
|
||||
@@ -33,10 +33,10 @@ namespace Disco.ClientBootstrapper
|
||||
|
||||
//Program.Status.UpdateStatus(null, null, "Testing UI");
|
||||
//Program.SleepThread(5000, false);
|
||||
Interop.InstallInterop.Install(this.InstallLocation, this.WimImageId, this.TempPath);
|
||||
if (this.mCompleteCallback != null)
|
||||
Interop.InstallInterop.Install(InstallLocation, WimImageId, TempPath);
|
||||
if (mCompleteCallback != null)
|
||||
{
|
||||
this.mCompleteCallback.BeginInvoke(null, null);
|
||||
mCompleteCallback.BeginInvoke(null, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
@@ -16,8 +15,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()
|
||||
@@ -41,7 +41,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(certFile).ToLower().Contains("temp"))
|
||||
_tempCerts.Add(cert.SerialNumber);
|
||||
Program.Status.UpdateStatus(null, null, string.Format("Added Root Certificate: {0}", cert.ShortSubjectName()));
|
||||
Program.Status.UpdateStatus(null, null, $"Added Root Certificate: {cert.ShortSubjectName()}");
|
||||
Program.SleepThread(500, false);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(certFile).ToLower().Contains("temp"))
|
||||
_tempCerts.Add(cert.SerialNumber);
|
||||
Program.Status.UpdateStatus(null, null, string.Format("Added Intermediate Certificate: {0}", cert.ShortSubjectName()));
|
||||
Program.Status.UpdateStatus(null, null, $"Added Intermediate Certificate: {cert.ShortSubjectName()}");
|
||||
Program.SleepThread(500, false);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(certFile).ToLower().Contains("temp"))
|
||||
_tempCerts.Add(cert.SerialNumber);
|
||||
Program.Status.UpdateStatus(null, null, string.Format("Added Host Certificate: {0}", cert.ShortSubjectName()));
|
||||
Program.Status.UpdateStatus(null, null, $"Added Host Certificate: {cert.ShortSubjectName()}");
|
||||
Program.SleepThread(500, false);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,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)
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new IOException(string.Format("Unable to delete folder: ", InstallLocation), ex);
|
||||
throw new IOException($"Unable to delete folder: {InstallLocation}", ex);
|
||||
}
|
||||
}
|
||||
if (!Directory.Exists(InstallLocation))
|
||||
@@ -66,7 +66,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
foreach (var file in Directory.EnumerateFiles(SourceLocation))
|
||||
{
|
||||
var fileName = Path.GetFileName(file);
|
||||
|
||||
|
||||
// Only Copy Certain Files
|
||||
|
||||
// Copy Wireless Certificates
|
||||
@@ -79,7 +79,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
if (fileName.StartsWith("WLAN_Profile_", StringComparison.OrdinalIgnoreCase) &&
|
||||
fileName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
|
||||
File.Copy(file, Path.Combine(InstallLocation, fileName));
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
using (var scriptsIniStreamWriter = new StreamWriter(scriptsIniStream, Encoding.Unicode))
|
||||
{
|
||||
scriptsIniStreamWriter.Write(string.Format("[Startup]{0}0CmdLine={1}{0}0Parameters=/AllowUninstall", Environment.NewLine, BootstrapperCmdLinePath));
|
||||
scriptsIniStreamWriter.Write($"[Startup]{Environment.NewLine}0CmdLine={BootstrapperCmdLinePath}{Environment.NewLine}0Parameters=/AllowUninstall");
|
||||
scriptsIniStreamWriter.Flush();
|
||||
}
|
||||
}
|
||||
@@ -193,18 +193,18 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
if (InstallLocation.EndsWith(".wim", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Offline File System (WIM)
|
||||
Program.Status.UpdateStatus("Installing Bootstrapper (Offline)", "Installing", string.Format("Install Location: {0}", InstallLocation));
|
||||
Program.Status.UpdateStatus("Installing Bootstrapper (Offline)", "Installing", $"Install Location: {InstallLocation}");
|
||||
Program.SleepThread(1000, false);
|
||||
|
||||
// Mount WIM
|
||||
int wimImageIndex = 0;
|
||||
using (var wim = new Interop.WIMInterop.WindowsImageContainer(InstallLocation, WIMInterop.WindowsImageContainer.CreateFileMode.OpenExisting, WIMInterop.WindowsImageContainer.CreateFileAccess.Write))
|
||||
using (var wim = new WIMInterop.WindowsImageContainer(InstallLocation, WIMInterop.WindowsImageContainer.CreateFileMode.OpenExisting, WIMInterop.WindowsImageContainer.CreateFileAccess.Write))
|
||||
{
|
||||
if (WimImageId == null)
|
||||
WimImageId = "1";
|
||||
if (!int.TryParse(WimImageId, out wimImageIndex))
|
||||
{
|
||||
Program.Status.UpdateStatus(null, "Analysing WIM", string.Format("Looking for Image Name: {0}", WimImageId));
|
||||
Program.Status.UpdateStatus(null, "Analysing WIM", $"Looking for Image Name: {WimImageId}");
|
||||
Program.SleepThread(500, false);
|
||||
for (int i = 0; i < wim.ImageCount; i++)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
if (wimImageInfoName != null && wimImageInfoName.InnerText.Equals(WimImageId, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
wimImageIndex = i + 1;
|
||||
Program.Status.UpdateStatus(null, "Analysing WIM", string.Format("Found Image Id '{0}' at Index {1}", WimImageId, wimImageIndex));
|
||||
Program.Status.UpdateStatus(null, "Analysing WIM", $"Found Image Id '{WimImageId}' at Index {wimImageIndex}");
|
||||
Program.SleepThread(500, false);
|
||||
break;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
}
|
||||
if (wimImageIndex == 0)
|
||||
{
|
||||
Program.Status.UpdateStatus(null, "Error", string.Format("Unable to load WIM Image Id: {0}", WimImageId));
|
||||
Program.Status.UpdateStatus(null, "Error", $"Unable to load WIM Image Id: {WimImageId}");
|
||||
Program.SleepThread(5000, false);
|
||||
return;
|
||||
}
|
||||
@@ -241,22 +241,22 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
Directory.CreateDirectory(wimTempMountPath);
|
||||
|
||||
bool wimCommitChanges = true;
|
||||
Interop.WIMInterop.WindowsImageContainer.NativeMethods.MessageCallback m_MessageCallback = null;
|
||||
WIMInterop.WindowsImageContainer.NativeMethods.MessageCallback m_MessageCallback = null;
|
||||
try
|
||||
{
|
||||
// Mount WIM
|
||||
Program.Status.UpdateStatus(null, "Mounting WIM", string.Format("Mounting WIM Image to '{0}'", wimMountPath));
|
||||
Program.Status.UpdateStatus(null, "Mounting WIM", $"Mounting WIM Image to '{wimMountPath}'");
|
||||
Program.SleepThread(500, false);
|
||||
m_MessageCallback = new Interop.WIMInterop.WindowsImageContainer.NativeMethods.MessageCallback(WimImageEventMessagePump);
|
||||
Interop.WIMInterop.WindowsImageContainer.NativeMethods.RegisterCallback(m_MessageCallback);
|
||||
m_MessageCallback = new WIMInterop.WindowsImageContainer.NativeMethods.MessageCallback(WimImageEventMessagePump);
|
||||
WIMInterop.WindowsImageContainer.NativeMethods.RegisterCallback(m_MessageCallback);
|
||||
|
||||
Interop.WIMInterop.WindowsImageContainer.NativeMethods.MountImage(wimMountPath, InstallLocation, wimImageIndex, wimTempMountPath);
|
||||
WIMInterop.WindowsImageContainer.NativeMethods.MountImage(wimMountPath, InstallLocation, wimImageIndex, wimTempMountPath);
|
||||
|
||||
// Load Local Machine Registry
|
||||
var wimHivePath = Path.Combine(wimMountPath, "Windows\\System32\\config\\SOFTWARE");
|
||||
Program.Status.UpdateStatus(null, "Mounting Offline Registry Hive", string.Format("Mounting Offline Registry Hive at '{0}'", wimHivePath));
|
||||
Program.Status.UpdateStatus(null, "Mounting Offline Registry Hive", $"Mounting Offline Registry Hive at '{wimHivePath}'");
|
||||
Program.SleepThread(500, false);
|
||||
using (var wimReg = new Interop.RegistryInterop(RegistryInterop.RegistryHives.HKEY_LOCAL_MACHINE, "DiscoClientBootstrapperWimHive", wimHivePath))
|
||||
using (var wimReg = new RegistryInterop(RegistryInterop.RegistryHives.HKEY_LOCAL_MACHINE, "DiscoClientBootstrapperWimHive", wimHivePath))
|
||||
{
|
||||
using (RegistryKey rootRegistryLocation = Registry.LocalMachine.OpenSubKey("DiscoClientBootstrapperWimHive", true))
|
||||
{
|
||||
@@ -268,7 +268,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
}
|
||||
|
||||
// Unload Local Machine Registry
|
||||
Program.Status.UpdateStatus(null, "Unmounting Offline Registry Hive", string.Format("Unmounting Offline Registry Hive at '{0}'", wimHivePath));
|
||||
Program.Status.UpdateStatus(null, "Unmounting Offline Registry Hive", $"Unmounting Offline Registry Hive at '{wimHivePath}'");
|
||||
Program.SleepThread(500, false);
|
||||
wimReg.Unload();
|
||||
}
|
||||
@@ -281,13 +281,13 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
finally
|
||||
{
|
||||
// Unmount WIM
|
||||
Program.Status.UpdateStatus(null, "Unmounting WIM", string.Format("Unmounting WIM Image at '{0}'", wimMountPath));
|
||||
Program.Status.UpdateStatus(null, "Unmounting WIM", $"Unmounting WIM Image at '{wimMountPath}'");
|
||||
Program.SleepThread(500, false);
|
||||
Interop.WIMInterop.WindowsImageContainer.NativeMethods.DismountImage(wimMountPath, InstallLocation, wimImageIndex, wimCommitChanges);
|
||||
WIMInterop.WindowsImageContainer.NativeMethods.DismountImage(wimMountPath, InstallLocation, wimImageIndex, wimCommitChanges);
|
||||
|
||||
if (m_MessageCallback != null)
|
||||
{
|
||||
Interop.WIMInterop.WindowsImageContainer.NativeMethods.UnregisterMessageCallback(m_MessageCallback);
|
||||
WIMInterop.WindowsImageContainer.NativeMethods.UnregisterMessageCallback(m_MessageCallback);
|
||||
m_MessageCallback = null;
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
else
|
||||
{
|
||||
// Online File System
|
||||
Program.Status.UpdateStatus("Installing Bootstrapper (Online)", "Installing", string.Format("Install Location: {0}", InstallLocation), true, -1);
|
||||
Program.Status.UpdateStatus("Installing Bootstrapper (Online)", "Installing", $"Install Location: {InstallLocation}", true, -1);
|
||||
Program.SleepThread(1000, false);
|
||||
string rootFileSystemLocation = Path.GetPathRoot(InstallLocation);
|
||||
RegistryKey rootRegistryLocation = Registry.LocalMachine.OpenSubKey("SOFTWARE", true);
|
||||
@@ -321,16 +321,16 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
IntPtr UserData
|
||||
)
|
||||
{
|
||||
uint status = (uint)Interop.WIMInterop.WindowsImageContainer.NativeMethods.WIMMessage.WIM_MSG_SUCCESS;
|
||||
Interop.WIMInterop.DefaultImageEventArgs eventArgs = new Interop.WIMInterop.DefaultImageEventArgs(wParam, lParam, UserData);
|
||||
uint status = (uint)WIMInterop.WindowsImageContainer.NativeMethods.WIMMessage.WIM_MSG_SUCCESS;
|
||||
WIMInterop.DefaultImageEventArgs eventArgs = new WIMInterop.DefaultImageEventArgs(wParam, lParam, UserData);
|
||||
|
||||
//System.Diagnostics.Debug.WriteLine(MessageId);
|
||||
|
||||
switch ((Interop.WIMInterop.WindowsImageContainer.ImageEventMessage)MessageId)
|
||||
switch ((WIMInterop.WindowsImageContainer.ImageEventMessage)MessageId)
|
||||
{
|
||||
|
||||
case Interop.WIMInterop.WindowsImageContainer.ImageEventMessage.Progress:
|
||||
case Interop.WIMInterop.WindowsImageContainer.ImageEventMessage.MountCleanupProgress:
|
||||
case WIMInterop.WindowsImageContainer.ImageEventMessage.Progress:
|
||||
case WIMInterop.WindowsImageContainer.ImageEventMessage.MountCleanupProgress:
|
||||
var timeRemainingMil = eventArgs.LeftParameter.ToInt32();
|
||||
string timeRemainingMessage;
|
||||
if (timeRemainingMil > 0)
|
||||
@@ -339,8 +339,8 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
timeRemainingMessage = "Calculating, please wait...";
|
||||
|
||||
var progress = eventArgs.WideParameter.ToInt32();
|
||||
Program.Status.UpdateStatus(null, null, string.Format("Time remaining: {0}", timeRemainingMessage), true, progress);
|
||||
|
||||
Program.Status.UpdateStatus(null, null, $"Time remaining: {timeRemainingMessage}", true, progress);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -17,8 +14,8 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
public string Name { get; set; }
|
||||
public string NetConnectionID { get; set; }
|
||||
public string MACAddress { get; set; }
|
||||
public UInt64 Speed { get; set; }
|
||||
public UInt16 LastConnectionStatus { get; set; }
|
||||
public ulong Speed { get; set; }
|
||||
public ushort LastConnectionStatus { get; set; }
|
||||
public bool IsWireless { get; set; }
|
||||
public string WirelessInterfaceDescription { get; set; }
|
||||
public int LastWirelessConnectionStatus { get; set; }
|
||||
@@ -30,51 +27,51 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
|
||||
private void UpdateFromWmi(ManagementObject wmiObject)
|
||||
{
|
||||
this.WmiPath = (string)wmiObject.GetPropertyValue("__PATH");
|
||||
this.Index = (UInt32)wmiObject.GetPropertyValue("Index");
|
||||
this.Guid = Guid.Parse((string)wmiObject.GetPropertyValue("GUID"));
|
||||
this.MACAddress = (string)wmiObject.GetPropertyValue("MACAddress");
|
||||
this.Name = (string)wmiObject.GetPropertyValue("Name");
|
||||
this.NetConnectionID = (string)wmiObject.GetPropertyValue("NetConnectionID");
|
||||
this.Speed = (UInt64)wmiObject.GetPropertyValue("Speed");
|
||||
var connectionStatus = ConnectionStatus;
|
||||
this.IsWireless = true;
|
||||
WmiPath = (string)wmiObject.GetPropertyValue("__PATH");
|
||||
Index = (uint)wmiObject.GetPropertyValue("Index");
|
||||
Guid = Guid.Parse((string)wmiObject.GetPropertyValue("GUID"));
|
||||
MACAddress = (string)wmiObject.GetPropertyValue("MACAddress");
|
||||
Name = (string)wmiObject.GetPropertyValue("Name");
|
||||
NetConnectionID = (string)wmiObject.GetPropertyValue("NetConnectionID");
|
||||
Speed = (ulong)wmiObject.GetPropertyValue("Speed");
|
||||
_ = ConnectionStatus;
|
||||
IsWireless = true;
|
||||
try
|
||||
{
|
||||
var wirelessConnectionStatus = WirelessConnectionStatus;
|
||||
}
|
||||
catch (Exception) {
|
||||
this.IsWireless = false;
|
||||
};
|
||||
catch (Exception)
|
||||
{
|
||||
IsWireless = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int WirelessConnectionStatus
|
||||
{
|
||||
get {
|
||||
if (this.IsWireless)
|
||||
get
|
||||
{
|
||||
if (IsWireless)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
uint negotiatedVersion;
|
||||
try
|
||||
{
|
||||
if (NetworkInterop.WlanOpenHandle(1, IntPtr.Zero, out negotiatedVersion, ref handle) != 0)
|
||||
if (NetworkInterop.WlanOpenHandle(1, IntPtr.Zero, out var negotiatedVersion, ref handle) != 0)
|
||||
throw new NotSupportedException("This network adapter does not support Wireless");
|
||||
|
||||
IntPtr ptr = new IntPtr();
|
||||
|
||||
uint dataSize;
|
||||
|
||||
var interfaceGuid = this.Guid;
|
||||
var interfaceGuid = Guid;
|
||||
|
||||
if (NetworkInterop.WlanQueryInterface(handle, ref interfaceGuid, NetworkInterop.WLAN_INTF_OPCODE.wlan_intf_opcode_interface_state, IntPtr.Zero, out dataSize, ref ptr, IntPtr.Zero) != 0)
|
||||
if (NetworkInterop.WlanQueryInterface(handle, ref interfaceGuid, NetworkInterop.WLAN_INTF_OPCODE.wlan_intf_opcode_interface_state, IntPtr.Zero, out var dataSize, ref ptr, IntPtr.Zero) != 0)
|
||||
throw new NotSupportedException("This network adapter does not support Wireless");
|
||||
|
||||
this.LastWirelessConnectionStatus = Marshal.ReadInt32(ptr);
|
||||
LastWirelessConnectionStatus = Marshal.ReadInt32(ptr);
|
||||
|
||||
|
||||
NetworkInterop.WlanFreeMemory(ptr);
|
||||
|
||||
return this.LastWirelessConnectionStatus;
|
||||
return LastWirelessConnectionStatus;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -114,46 +111,46 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
}
|
||||
}
|
||||
|
||||
public UInt16 ConnectionStatus
|
||||
public ushort ConnectionStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var wmiObject = new ManagementObject(this.WmiPath))
|
||||
using (var wmiObject = new ManagementObject(WmiPath))
|
||||
{
|
||||
this.LastConnectionStatus = (UInt16)wmiObject.GetPropertyValue("NetConnectionStatus");
|
||||
LastConnectionStatus = (ushort)wmiObject.GetPropertyValue("NetConnectionStatus");
|
||||
}
|
||||
return this.LastConnectionStatus;
|
||||
return LastConnectionStatus;
|
||||
}
|
||||
}
|
||||
public string ConnectionStatusMeaning(UInt16 status)
|
||||
public string ConnectionStatusMeaning(ushort status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case (UInt16)0:
|
||||
case (ushort)0:
|
||||
return "Disconnected";
|
||||
case (UInt16)1:
|
||||
case (ushort)1:
|
||||
return "Connecting";
|
||||
case (UInt16)2:
|
||||
case (ushort)2:
|
||||
return "Connected";
|
||||
case (UInt16)3:
|
||||
case (ushort)3:
|
||||
return "Disconnecting";
|
||||
case (UInt16)4:
|
||||
case (ushort)4:
|
||||
return "Hardware not present";
|
||||
case (UInt16)5:
|
||||
case (ushort)5:
|
||||
return "Hardware disabled";
|
||||
case (UInt16)6:
|
||||
case (ushort)6:
|
||||
return "Hardware malfunction";
|
||||
case (UInt16)7:
|
||||
case (ushort)7:
|
||||
return "Media disconnected";
|
||||
case (UInt16)8:
|
||||
case (ushort)8:
|
||||
return "Authenticating";
|
||||
case (UInt16)9:
|
||||
case (ushort)9:
|
||||
return "Authentication succeeded";
|
||||
case (UInt16)10:
|
||||
case (ushort)10:
|
||||
return "Authentication failed";
|
||||
case (UInt16)11:
|
||||
case (ushort)11:
|
||||
return "Invalid address";
|
||||
case (UInt16)12:
|
||||
case (ushort)12:
|
||||
return "Credentials required";
|
||||
default:
|
||||
return "Unknown";
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Management;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Xml;
|
||||
|
||||
@@ -165,7 +164,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
}
|
||||
}
|
||||
|
||||
public static bool PingDisco(string ServerName)
|
||||
public static bool PingDiscoIct(string ServerName)
|
||||
{
|
||||
using (Ping p = new Ping())
|
||||
{
|
||||
@@ -197,11 +196,10 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
|
||||
IntPtr wlanHandle = IntPtr.Zero;
|
||||
uint negotiatedVersion;
|
||||
|
||||
try
|
||||
{
|
||||
if (WlanOpenHandle(1, IntPtr.Zero, out negotiatedVersion, ref wlanHandle) != 0)
|
||||
if (WlanOpenHandle(1, IntPtr.Zero, out var negotiatedVersion, ref wlanHandle) != 0)
|
||||
throw new NotSupportedException("This device does not support Wireless");
|
||||
|
||||
// Add Profile to Each Wireless Adapter
|
||||
@@ -212,12 +210,12 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
{
|
||||
if (inlineWirelessProfile.AddProfile(wlanHandle, na.Guid))
|
||||
{
|
||||
Program.Status.UpdateStatus(null, null, string.Format("Added Wireless Profile: {0}", inlineWirelessProfile.ProfileName));
|
||||
Program.Status.UpdateStatus(null, null, $"Added Wireless Profile: {inlineWirelessProfile.ProfileName}");
|
||||
Program.SleepThread(500, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.Status.UpdateStatus(null, null, string.Format("Unable to add Wireless Profile: {0}", inlineWirelessProfile.ProfileName));
|
||||
Program.Status.UpdateStatus(null, null, $"Unable to add Wireless Profile: {inlineWirelessProfile.ProfileName}");
|
||||
Program.SleepThread(5000, false);
|
||||
}
|
||||
}
|
||||
@@ -226,7 +224,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
finally
|
||||
{
|
||||
if (wlanHandle != IntPtr.Zero)
|
||||
NetworkInterop.WlanCloseHandle(wlanHandle, IntPtr.Zero);
|
||||
WlanCloseHandle(wlanHandle, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,10 +238,9 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
public bool AddProfile(IntPtr WlanHandle, Guid interfaceGuid)
|
||||
{
|
||||
var pInterfaceGuid = interfaceGuid;
|
||||
var pProfileXml = this.ProfileXml;
|
||||
var pProfileXml = ProfileXml;
|
||||
uint pFlag = 0;
|
||||
uint failReason;
|
||||
return (WlanSetProfile(WlanHandle, ref pInterfaceGuid, pFlag, pProfileXml, null, true, IntPtr.Zero, out failReason) == 0);
|
||||
return WlanSetProfile(WlanHandle, ref pInterfaceGuid, pFlag, pProfileXml, null, true, IntPtr.Zero, out _) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +277,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
WlanGetProfileList(WlanHandle, ref pInterfaceGuid, new IntPtr(), ref ppProfileList);
|
||||
WLAN_PROFILE_INFO_LIST wlanProfileInfoList = new WLAN_PROFILE_INFO_LIST(ppProfileList);
|
||||
|
||||
NetworkInterop.WlanFreeMemory(ppProfileList);
|
||||
WlanFreeMemory(ppProfileList);
|
||||
|
||||
return wlanProfileInfoList;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Disco.ClientBootstrapper.Interop
|
||||
@@ -33,7 +30,7 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
private static extern int LookupPrivilegeValue(string lpsystemname, string lpname, [MarshalAs(UnmanagedType.Struct)] ref LUID lpLuid);
|
||||
|
||||
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern int AdjustTokenPrivileges(int tokenhandle, int disableprivs, [MarshalAs(UnmanagedType.Struct)]ref TOKEN_PRIVILEGES Newstate, int bufferlength, int PreivousState, int Returnlength);
|
||||
private static extern int AdjustTokenPrivileges(int tokenhandle, int disableprivs, [MarshalAs(UnmanagedType.Struct)] ref TOKEN_PRIVILEGES Newstate, int bufferlength, int PreivousState, int Returnlength);
|
||||
|
||||
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern int RegLoadKey(uint hKey, string lpSubKey, string lpFile);
|
||||
@@ -61,16 +58,15 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
public RegistryInterop(RegistryHives hive, string subKey, string filePath)
|
||||
{
|
||||
int token = 0;
|
||||
int retval = 0;
|
||||
|
||||
TOKEN_PRIVILEGES TP = new TOKEN_PRIVILEGES();
|
||||
TOKEN_PRIVILEGES TP2 = new TOKEN_PRIVILEGES();
|
||||
LUID RestoreLuid = new LUID();
|
||||
LUID BackupLuid = new LUID();
|
||||
|
||||
retval = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref token);
|
||||
retval = LookupPrivilegeValue(null, SE_RESTORE_NAME, ref RestoreLuid);
|
||||
retval = LookupPrivilegeValue(null, SE_BACKUP_NAME, ref BackupLuid);
|
||||
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref token);
|
||||
LookupPrivilegeValue(null, SE_RESTORE_NAME, ref RestoreLuid);
|
||||
LookupPrivilegeValue(null, SE_BACKUP_NAME, ref BackupLuid);
|
||||
TP.PrivilegeCount = 1;
|
||||
TP.Attributes = SE_PRIVILEGE_ENABLED;
|
||||
TP.Luid = RestoreLuid;
|
||||
@@ -78,25 +74,25 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
TP2.Attributes = SE_PRIVILEGE_ENABLED;
|
||||
TP2.Luid = BackupLuid;
|
||||
|
||||
retval = AdjustTokenPrivileges(token, 0, ref TP, 1024, 0, 0);
|
||||
retval = AdjustTokenPrivileges(token, 0, ref TP2, 1024, 0, 0);
|
||||
AdjustTokenPrivileges(token, 0, ref TP, 1024, 0, 0);
|
||||
AdjustTokenPrivileges(token, 0, ref TP2, 1024, 0, 0);
|
||||
|
||||
uint regHive = (uint)hive;
|
||||
|
||||
this.Hive = hive;
|
||||
this.SubKey = subKey;
|
||||
Hive = hive;
|
||||
SubKey = subKey;
|
||||
RegLoadKey(regHive, subKey, filePath);
|
||||
this.IsUnloaded = false;
|
||||
IsUnloaded = false;
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
if (!IsUnloaded)
|
||||
{
|
||||
uint regHive = (uint)this.Hive;
|
||||
string subKey = this.SubKey;
|
||||
uint regHive = (uint)Hive;
|
||||
string subKey = SubKey;
|
||||
RegUnLoadKey(regHive, subKey);
|
||||
this.IsUnloaded = true;
|
||||
IsUnloaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Disco.ClientBootstrapper.Interop
|
||||
@@ -43,21 +39,20 @@ namespace Disco.ClientBootstrapper.Interop
|
||||
// End Removed 2012-11-23 G#
|
||||
|
||||
// Added 2012-11-23 G# - Migrate to Win32 PInvoke Shutdown
|
||||
bool result;
|
||||
TokPriv1Luid tp;
|
||||
|
||||
IntPtr hproc = GetCurrentProcess();
|
||||
IntPtr htok = IntPtr.Zero;
|
||||
|
||||
result = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
|
||||
OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
|
||||
|
||||
tp.Count = 1;
|
||||
tp.Luid = 0;
|
||||
tp.Attr = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
result = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
|
||||
result = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
|
||||
result = ExitWindowsEx(flag, 0);
|
||||
LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
|
||||
AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
|
||||
ExitWindowsEx(flag, 0);
|
||||
// End Added 2012-11-23 G#
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
{
|
||||
@@ -140,8 +138,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
CreateFileAccessPrivate fileAccess = GetMappedFileAccess(access);
|
||||
if (fileAccess == CreateFileAccessPrivate.Read && (!File.Exists(imageFilePath) || (CreateFileMode.OpenExisting != mode)))
|
||||
{
|
||||
throw new System.UnauthorizedAccessException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Read access can be specified only with OpenExisting mode or OpenAlways mode when the .wim file does not exist."));
|
||||
throw new UnauthorizedAccessException("Read access can be specified only with OpenExisting mode or OpenAlways mode when the .wim file does not exist.");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -152,9 +149,9 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
m_ImageContainerHandle = NativeMethods.CreateFile(imageFilePath, (uint)fileAccess, (uint)mode);
|
||||
m_WindowsImageFilePath = imageFilePath;
|
||||
}
|
||||
catch (System.DllNotFoundException ex)
|
||||
catch (DllNotFoundException ex)
|
||||
{
|
||||
throw new System.DllNotFoundException(string.Format(CultureInfo.CurrentCulture,
|
||||
throw new DllNotFoundException(string.Format(
|
||||
"Unable to load WIM libraries. Make sure the correct DLLs are present (Wimgapi.dll and Xmlrw.dll)."), ex.InnerException);
|
||||
}
|
||||
|
||||
@@ -164,7 +161,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//Set the temporary path so that we can write to an image. This
|
||||
//cannot be %TEMP% as it does not exist on Windows PE
|
||||
//
|
||||
string tempDirectory = System.Environment.GetEnvironmentVariable("systemdrive");
|
||||
string tempDirectory = Environment.GetEnvironmentVariable("systemdrive");
|
||||
NativeMethods.SetTemporaryPath(m_ImageContainerHandle, tempDirectory);
|
||||
|
||||
}
|
||||
@@ -173,8 +170,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to open the .wim file {0}.", imageFilePath));
|
||||
throw new InvalidOperationException($"Unable to open the .wim file {imageFilePath}.");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -481,7 +477,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//
|
||||
//Never commit changes when destroying this object.
|
||||
//
|
||||
this.DismountImage(false);
|
||||
DismountImage(false);
|
||||
}
|
||||
GC.KeepAlive(this);
|
||||
}
|
||||
@@ -576,12 +572,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//1. Leading 0xFEFF
|
||||
//2. Be in <IMAGE></IMAGE>
|
||||
//
|
||||
string formattedXml = String.Format(CultureInfo.InvariantCulture,
|
||||
"{0}{1}{2}{3}",
|
||||
UNICODE_FILE_MARKER,
|
||||
"<IMAGE>",
|
||||
imageInformation,
|
||||
"</IMAGE>");
|
||||
string formattedXml = $"{UNICODE_FILE_MARKER}{"<IMAGE>"}{imageInformation}{"</IMAGE>"}";
|
||||
|
||||
NativeMethods.SetImageInformation(m_ImageHandle, formattedXml);
|
||||
GC.KeepAlive(this);
|
||||
@@ -597,7 +588,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//Mount the image
|
||||
//
|
||||
m_MountedPath = pathToMountTo;
|
||||
NativeMethods.MountImage(pathToMountTo, m_ParentWindowsImageFilePath, m_Index, System.IO.Path.GetTempPath());
|
||||
NativeMethods.MountImage(pathToMountTo, m_ParentWindowsImageFilePath, m_Index, Path.GetTempPath());
|
||||
m_Mounted = true;
|
||||
}
|
||||
|
||||
@@ -650,7 +641,8 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
///Private null constructor
|
||||
///</summary>
|
||||
private
|
||||
NativeMethods() { }
|
||||
NativeMethods()
|
||||
{ }
|
||||
|
||||
[DllImport("Wimgapi.dll", ExactSpelling = true,
|
||||
EntryPoint = "WIMCreateFile",
|
||||
@@ -684,16 +676,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
IntPtr windowsImageHandle = IntPtr.Zero;
|
||||
int rc = -1;
|
||||
|
||||
windowsImageHandle = NativeMethods.WimCreateFile(imageFile, access, mode, 0, 0, out creationResult);
|
||||
windowsImageHandle = WimCreateFile(imageFile, access, mode, 0, 0, out _);
|
||||
rc = Marshal.GetLastWin32Error();
|
||||
if (windowsImageHandle == IntPtr.Zero)
|
||||
{
|
||||
//
|
||||
//Everything failed; throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to open/create .wim file {0}. Error = {1}",
|
||||
imageFile, rc));
|
||||
throw new InvalidOperationException($"Unable to open/create .wim file {imageFile}. Error = {rc}");
|
||||
}
|
||||
|
||||
return windowsImageHandle;
|
||||
@@ -721,15 +711,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
void
|
||||
CloseHandle(IntPtr handle)
|
||||
{
|
||||
bool status = NativeMethods.WimCloseHandle(handle);
|
||||
bool status = WimCloseHandle(handle);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (status == false)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to close image handle. Error = {0}", rc));
|
||||
throw new InvalidOperationException($"Unable to close image handle. Error = {rc}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,14 +746,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
void
|
||||
SetTemporaryPath(IntPtr handle, string temporaryPath)
|
||||
{
|
||||
bool status = NativeMethods.WimSetTemporaryPath(handle, temporaryPath);
|
||||
bool status = WimSetTemporaryPath(handle, temporaryPath);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (status == false)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unable to set temporary path. Error = {0}", rc));
|
||||
throw new InvalidOperationException($"Unable to set temporary path. Error = {rc}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,14 +783,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
{
|
||||
//Load the image data based on the .wim handle
|
||||
//
|
||||
IntPtr hWim = NativeMethods.WimLoadImage(handle, (uint)imageIndex);
|
||||
IntPtr hWim = WimLoadImage(handle, (uint)imageIndex);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (hWim == IntPtr.Zero)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unable to load image. Error = {0}", rc));
|
||||
throw new InvalidOperationException($"Unable to load image. Error = {rc}");
|
||||
}
|
||||
|
||||
return hWim;
|
||||
@@ -832,15 +821,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
IntPtr
|
||||
CaptureImage(IntPtr handle, string path)
|
||||
{
|
||||
IntPtr hImage = NativeMethods.WimCaptureImage(handle, path, 0);
|
||||
IntPtr hImage = WimCaptureImage(handle, path, 0);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (hImage == IntPtr.Zero)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Failed to capture image from {0}. Error = {1}", path, rc));
|
||||
throw new InvalidOperationException($"Failed to capture image from {path}. Error = {rc}");
|
||||
}
|
||||
return hImage;
|
||||
}
|
||||
@@ -873,14 +861,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
int
|
||||
GetImageCount(IntPtr windowsImageHandle)
|
||||
{
|
||||
int count = NativeMethods.WimGetImageCount(windowsImageHandle);
|
||||
int count = WimGetImageCount(windowsImageHandle);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (count == -1)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unable to get image count. Error = {0}", rc));
|
||||
throw new InvalidOperationException($"Unable to get image count. Error = {rc}");
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -971,28 +959,25 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
|
||||
try
|
||||
{
|
||||
status = NativeMethods.WimMountImage(mountPath,
|
||||
status = WimMountImage(mountPath,
|
||||
windowsImageFileName,
|
||||
(uint)imageIndex,
|
||||
temporaryPath);
|
||||
rc = Marshal.GetLastWin32Error();
|
||||
}
|
||||
catch (System.StackOverflowException)
|
||||
catch (StackOverflowException)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to mount image {0} to {1}.", windowsImageFileName, mountPath));
|
||||
throw new InvalidOperationException($"Unable to mount image {windowsImageFileName} to {mountPath}.");
|
||||
}
|
||||
if (status == false)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to mount image {0} to {1}. Error = {2}",
|
||||
windowsImageFileName, mountPath, rc));
|
||||
throw new InvalidOperationException($"Unable to mount image {windowsImageFileName} to {mountPath}. Error = {rc}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1022,15 +1007,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//
|
||||
//Call WimApplyImage always with the Index flag for performance reasons.
|
||||
//
|
||||
bool status = NativeMethods.WimApplyImage(imageHandle, applicationPath, NativeMethods.WIM_FLAG_INDEX);
|
||||
bool status = WimApplyImage(imageHandle, applicationPath, WIM_FLAG_INDEX);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (status == false)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to apply image to {0}. Error = {1}", applicationPath, rc));
|
||||
throw new InvalidOperationException($"Unable to apply image to {applicationPath}. Error = {rc}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1062,7 +1046,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
IntPtr info = IntPtr.Zero, sizeOfInfo = IntPtr.Zero;
|
||||
bool status;
|
||||
|
||||
status = NativeMethods.WimGetImageInformation(handle, out info, out sizeOfInfo);
|
||||
status = WimGetImageInformation(handle, out info, out _);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
|
||||
if (status == false)
|
||||
@@ -1070,8 +1054,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to get image information. Error = {0}", rc));
|
||||
throw new InvalidOperationException($"Unable to get image information. Error = {rc}");
|
||||
}
|
||||
string s = Marshal.PtrToStringUni(info);
|
||||
|
||||
@@ -1112,15 +1095,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
IntPtr xmlBuffer = Marshal.AllocHGlobal(byteBufferSize);
|
||||
Marshal.Copy(byteBuffer, 0, xmlBuffer, byteBufferSize);
|
||||
|
||||
bool status = NativeMethods.WimSetImageInformation(handle, xmlBuffer, (uint)byteBufferSize);
|
||||
bool status = WimSetImageInformation(handle, xmlBuffer, (uint)byteBufferSize);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (status == false)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to set image information. Error = {0}", rc));
|
||||
throw new InvalidOperationException($"Unable to set image information. Error = {rc}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1153,16 +1135,15 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
|
||||
try
|
||||
{
|
||||
status = NativeMethods.WimUnmountImage(mountPath, wimdowsImageFileName, (uint)imageIndex, commitChanges);
|
||||
status = WimUnmountImage(mountPath, wimdowsImageFileName, (uint)imageIndex, commitChanges);
|
||||
rc = Marshal.GetLastWin32Error();
|
||||
}
|
||||
catch (System.StackOverflowException ex)
|
||||
catch (StackOverflowException ex)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.StackOverflowException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to unmount image {0} from {1}.", wimdowsImageFileName, mountPath),
|
||||
throw new StackOverflowException($"Unable to unmount image {wimdowsImageFileName} from {mountPath}.",
|
||||
ex.InnerException);
|
||||
}
|
||||
if (status == false)
|
||||
@@ -1170,9 +1151,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
"Unable to unmount image {0} from {1}. Error = {2}",
|
||||
wimdowsImageFileName, mountPath, rc));
|
||||
throw new InvalidOperationException($"Unable to unmount image {wimdowsImageFileName} from {mountPath}. Error = {rc}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1221,14 +1200,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
void
|
||||
RegisterCallback(MessageCallback callback)
|
||||
{
|
||||
uint callbackZeroBasedIndex = NativeMethods.WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero);
|
||||
WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
if (rc != 0)
|
||||
{
|
||||
//
|
||||
//Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unable to register message callback."));
|
||||
throw new InvalidOperationException("Unable to register message callback.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1253,14 +1232,14 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
void
|
||||
UnregisterMessageCallback(MessageCallback registeredCallback)
|
||||
{
|
||||
bool status = NativeMethods.WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback);
|
||||
int rc = Marshal.GetLastWin32Error();
|
||||
bool status = WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback);
|
||||
_ = Marshal.GetLastWin32Error();
|
||||
if (status != true)
|
||||
{
|
||||
//
|
||||
// Throw an exception
|
||||
//
|
||||
throw new System.InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Unable to unregister message callback."));
|
||||
throw new InvalidOperationException("Unable to unregister message callback.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,13 +1337,13 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
fileAccess = CreateFileAccessPrivate.Write;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "No file access level specified."));
|
||||
throw new ArgumentException("No file access level specified.");
|
||||
}
|
||||
return fileAccess;
|
||||
}
|
||||
|
||||
//[CLSCompliant(false)]
|
||||
[FlagsAttribute]
|
||||
[Flags]
|
||||
private
|
||||
enum
|
||||
CreateFileAccessPrivate : uint
|
||||
@@ -1436,7 +1415,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
|
||||
///Abort.
|
||||
///</summary>
|
||||
Abort = NativeMethods.WIMMessage.WIM_MSG_ABORT_IMAGE,
|
||||
|
||||
|
||||
MountCleanupProgress = NativeMethods.WIMMessage.WIM_MSG_MOUNT_CLEANUP_PROGRESS
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Disco.ClientBootstrapper
|
||||
namespace Disco.ClientBootstrapper
|
||||
{
|
||||
class NullStatus : IStatus
|
||||
{
|
||||
|
||||
@@ -86,15 +86,15 @@ namespace Disco.ClientBootstrapper
|
||||
{
|
||||
try
|
||||
{
|
||||
string AppErrorPath = string.Format("{0}{1}", System.Reflection.Assembly.GetExecutingAssembly().Location, ".errors.txt");
|
||||
string AppErrorPath = $"{System.Reflection.Assembly.GetExecutingAssembly().Location}.errors.txt";
|
||||
System.Text.StringBuilder ErrorMessage = new System.Text.StringBuilder();
|
||||
ErrorMessage.AppendLine();
|
||||
ErrorMessage.AppendLine(DateTime.Now.ToLongDateString());
|
||||
ErrorMessage.AppendLine(DateTime.Now.ToLongTimeString());
|
||||
ErrorMessage.AppendLine(string.Format("Type: {0}", ex.GetType().FullName));
|
||||
ErrorMessage.AppendLine(string.Format("Message: {0}", ex.Message));
|
||||
ErrorMessage.AppendLine(string.Format("Source: {0}", ex.Source));
|
||||
ErrorMessage.AppendLine(string.Format("Stack: {0}", ex.StackTrace));
|
||||
ErrorMessage.AppendLine($"Type: {ex.GetType().FullName}");
|
||||
ErrorMessage.AppendLine($"Message: {ex.Message}");
|
||||
ErrorMessage.AppendLine($"Source: {ex.Source}");
|
||||
ErrorMessage.AppendLine($"Stack: {ex.StackTrace}");
|
||||
System.IO.File.AppendAllText(AppErrorPath, ErrorMessage.ToString());
|
||||
}
|
||||
catch (Exception) { }
|
||||
@@ -118,18 +118,17 @@ namespace Disco.ClientBootstrapper
|
||||
SleepThread(4000, true);
|
||||
Interop.ShutdownInterop.Shutdown();
|
||||
}
|
||||
else if (PostBootstrapperActions.Contains("Reboot"))
|
||||
{
|
||||
Status.UpdateStatus("System Preparation (Bootstrapper)", "Rebooting; Finished...", string.Empty, false, 0);
|
||||
SleepThread(4000, true);
|
||||
Interop.ShutdownInterop.Reboot();
|
||||
}
|
||||
else
|
||||
if (PostBootstrapperActions.Contains("Reboot"))
|
||||
{
|
||||
Status.UpdateStatus("System Preparation (Bootstrapper)", "Rebooting; Finished...", string.Empty, false, 0);
|
||||
SleepThread(4000, true);
|
||||
Interop.ShutdownInterop.Reboot();
|
||||
}
|
||||
else
|
||||
{
|
||||
Status.UpdateStatus("System Preparation (Bootstrapper)", "Starting System; Finished...", string.Empty, false, 0);
|
||||
SleepThread(2000, true);
|
||||
}
|
||||
{
|
||||
Status.UpdateStatus("System Preparation (Bootstrapper)", "Starting System; Finished...", string.Empty, false, 0);
|
||||
SleepThread(2000, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -154,11 +153,11 @@ namespace Disco.ClientBootstrapper
|
||||
{
|
||||
if (BootstrapperLoop.LoopThread != null)
|
||||
{
|
||||
if (BootstrapperLoop.LoopThread.ThreadState == System.Threading.ThreadState.WaitSleepJoin)
|
||||
if (BootstrapperLoop.LoopThread.ThreadState == ThreadState.WaitSleepJoin)
|
||||
{
|
||||
BootstrapperLoop.LoopThread.Interrupt();
|
||||
}
|
||||
if (BootstrapperLoop.LoopThread.ThreadState == System.Threading.ThreadState.Running)
|
||||
if (BootstrapperLoop.LoopThread.ThreadState == ThreadState.Running)
|
||||
{
|
||||
BootstrapperLoop.LoopThread.Abort();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyFileVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyVersion("2.5.25262.0000")]
|
||||
[assembly: AssemblyFileVersion("2.5.25262.0000")]
|
||||
@@ -15,6 +15,6 @@
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -28,17 +28,17 @@ namespace Disco.Data.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConfigurationCache.GetScopeKeys(Database, this.Scope);
|
||||
return ConfigurationCache.GetScopeKeys(Database, Scope);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetValue<T>(string Key, T Value)
|
||||
{
|
||||
ConfigurationCache.SetValue(Database, this.Scope, Key, Value);
|
||||
ConfigurationCache.Helpers<T>.SetValue(Database, 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, Scope, Key, Default);
|
||||
}
|
||||
|
||||
protected void Set<T>(T Value, [CallerMemberName] string Key = null)
|
||||
@@ -46,7 +46,7 @@ namespace Disco.Data.Configuration
|
||||
if (Key == null)
|
||||
throw new ArgumentNullException("Key");
|
||||
|
||||
this.SetValue(Key, Value);
|
||||
SetValue(Key, Value);
|
||||
}
|
||||
|
||||
protected T Get<T>(T Default, [CallerMemberName] string Key = null)
|
||||
@@ -54,17 +54,17 @@ namespace Disco.Data.Configuration
|
||||
if (Key == null)
|
||||
throw new ArgumentNullException("Key");
|
||||
|
||||
return this.GetValue(Key, Default);
|
||||
return GetValue(Key, Default);
|
||||
}
|
||||
|
||||
protected void SetObsfucated(string Value, [CallerMemberName] string Key = null)
|
||||
{
|
||||
this.Set(Value.Obsfucate(), Key);
|
||||
Set(Value.Obsfucate(), Key);
|
||||
}
|
||||
|
||||
protected string GetDeobsfucated(string Default, [CallerMemberName] string Key = null)
|
||||
{
|
||||
var obsfucatedValue = this.Get<string>(null, Key);
|
||||
var obsfucatedValue = Get<string>(null, Key);
|
||||
|
||||
if (obsfucatedValue == null)
|
||||
return Default;
|
||||
@@ -74,35 +74,35 @@ namespace Disco.Data.Configuration
|
||||
|
||||
protected void RemoveScope()
|
||||
{
|
||||
ConfigurationCache.RemoveScope(Database, this.Scope);
|
||||
ConfigurationCache.RemoveScope(Database, Scope);
|
||||
}
|
||||
|
||||
protected void RemoveItem(string Key)
|
||||
{
|
||||
ConfigurationCache.RemoveScopeKey(Database, this.Scope, Key);
|
||||
ConfigurationCache.RemoveScopeKey(Database, Scope, Key);
|
||||
}
|
||||
|
||||
[Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")]
|
||||
protected void SetAsJson<T>(T Value, [CallerMemberName] string Key = null)
|
||||
{
|
||||
this.Set(Value, Key);
|
||||
Set(Value, Key);
|
||||
}
|
||||
|
||||
[Obsolete("Types are automatically serialized/deserialized if required, use Get<T>(T Default) instead.")]
|
||||
protected T GetFromJson<T>(T Default, [CallerMemberName] string Key = null)
|
||||
{
|
||||
return this.Get(Default, Key);
|
||||
return Get(Default, Key);
|
||||
}
|
||||
|
||||
[Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")]
|
||||
protected void SetAsEnum<T>(T Value, [CallerMemberName] string Key = null)
|
||||
{
|
||||
this.Set(Value, Key);
|
||||
Set(Value, Key);
|
||||
}
|
||||
[Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")]
|
||||
protected T GetFromEnum<T>(T Default, [CallerMemberName] string Key = null)
|
||||
{
|
||||
return this.Get(Default, Key);
|
||||
return Get(Default, Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace Disco.Data.Configuration
|
||||
|
||||
private static ConfigurationCacheType Cache(DiscoDataContext Database)
|
||||
{
|
||||
if (ConfigurationCache.cacheStore == null)
|
||||
if (cacheStore == null)
|
||||
{
|
||||
lock (configChangeLock)
|
||||
{
|
||||
if (ConfigurationCache.cacheStore == null)
|
||||
if (cacheStore == null)
|
||||
{
|
||||
if (Database == null)
|
||||
throw new InvalidOperationException("The Configuration must be loaded at least once before a Cache-Only Configuration Context is used");
|
||||
@@ -46,18 +46,16 @@ namespace Disco.Data.Configuration
|
||||
}
|
||||
}
|
||||
|
||||
return ConfigurationCache.cacheStore;
|
||||
return cacheStore;
|
||||
}
|
||||
|
||||
private static ConfigurationCacheItemType CacheGetItem(DiscoDataContext Database, string Scope, string Key)
|
||||
{
|
||||
var cache = Cache(Database);
|
||||
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
if (cache.TryGetValue(Scope, out scopeCache))
|
||||
if (cache.TryGetValue(Scope, out var scopeCache))
|
||||
{
|
||||
ConfigurationCacheItemType item = default(ConfigurationCacheItemType);
|
||||
if (scopeCache.TryGetValue(Key, out item))
|
||||
if (scopeCache.TryGetValue(Key, out var item))
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -93,8 +91,7 @@ namespace Disco.Data.Configuration
|
||||
Database.ConfigurationItems.Add(configItem);
|
||||
|
||||
// Add Item to Cache
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
if (!cacheStore.TryGetValue(Scope, out scopeCache))
|
||||
if (!cacheStore.TryGetValue(Scope, out var scopeCache))
|
||||
{
|
||||
scopeCache = new ConfigurationCacheScopeType();
|
||||
cacheStore.TryAdd(Scope, scopeCache);
|
||||
@@ -134,10 +131,9 @@ namespace Disco.Data.Configuration
|
||||
Database.ConfigurationItems.Remove(configItem);
|
||||
|
||||
// Remove item from Cache
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
if (cacheStore.TryGetValue(Scope, out scopeCache))
|
||||
if (cacheStore.TryGetValue(Scope, out var scopeCache))
|
||||
{
|
||||
scopeCache.TryRemove(Key, out item);
|
||||
scopeCache.TryRemove(Key, out _);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -148,8 +144,7 @@ namespace Disco.Data.Configuration
|
||||
configItem.Value = Value;
|
||||
|
||||
// Update Cache
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
if (cacheStore.TryGetValue(Scope, out scopeCache))
|
||||
if (cacheStore.TryGetValue(Scope, out var scopeCache))
|
||||
{
|
||||
scopeCache.TryRemove(Key, out item);
|
||||
item = new ConfigurationCacheItemType(configItem, ObjectValue);
|
||||
@@ -165,10 +160,9 @@ namespace Disco.Data.Configuration
|
||||
}
|
||||
private static ConfigurationCacheItemType SetItemTypeValue(ConfigurationCacheItemType ExistingItem, object Value)
|
||||
{
|
||||
var cache = ConfigurationCache.cacheStore;
|
||||
var cache = cacheStore;
|
||||
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
if (cache.TryGetValue(ExistingItem.Item1.Scope, out scopeCache))
|
||||
if (cache.TryGetValue(ExistingItem.Item1.Scope, out var scopeCache))
|
||||
{
|
||||
ConfigurationCacheItemType newItem = new ConfigurationCacheItemType(ExistingItem.Item1, Value);
|
||||
scopeCache.TryUpdate(ExistingItem.Item1.Key, newItem, ExistingItem);
|
||||
@@ -183,18 +177,18 @@ namespace Disco.Data.Configuration
|
||||
#region Helpers
|
||||
private static bool IsConvertableFromString(Type t)
|
||||
{
|
||||
if (t == typeof(Boolean) ||
|
||||
t == typeof(Char) ||
|
||||
t == typeof(SByte) ||
|
||||
t == typeof(Byte) ||
|
||||
t == typeof(Int16) || t == typeof(UInt16) ||
|
||||
t == typeof(Int32) || t == typeof(UInt32) ||
|
||||
t == typeof(Int64) || t == typeof(UInt64) ||
|
||||
t == typeof(Single) ||
|
||||
t == typeof(Double) ||
|
||||
t == typeof(Decimal) ||
|
||||
if (t == typeof(bool) ||
|
||||
t == typeof(char) ||
|
||||
t == typeof(sbyte) ||
|
||||
t == typeof(byte) ||
|
||||
t == typeof(short) || t == typeof(ushort) ||
|
||||
t == typeof(int) || t == typeof(uint) ||
|
||||
t == typeof(long) || t == typeof(ulong) ||
|
||||
t == typeof(float) ||
|
||||
t == typeof(double) ||
|
||||
t == typeof(decimal) ||
|
||||
t == typeof(DateTime) ||
|
||||
t == typeof(String))
|
||||
t == typeof(string))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@@ -202,89 +196,136 @@ 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 if (itemType.IsGenericType &&
|
||||
itemType.GetGenericTypeDefinition() == typeof(Nullable<>) &&
|
||||
IsConvertableFromString(Nullable.GetUnderlyingType(itemType)))
|
||||
{
|
||||
// nullable
|
||||
itemValue = (T)Convert.ChangeType(item.Item1.Value, Nullable.GetUnderlyingType(itemType));
|
||||
}
|
||||
else if (itemType == typeof(Guid))
|
||||
{
|
||||
// guid
|
||||
itemValue = new Guid(item.Item1.Value);
|
||||
}
|
||||
else if (itemType == typeof(Guid?))
|
||||
{
|
||||
// guid
|
||||
if (string.IsNullOrEmpty(item.Item1.Value))
|
||||
itemValue = null;
|
||||
else
|
||||
itemValue = new Guid(item.Item1.Value);
|
||||
}
|
||||
else if (itemType == typeof(byte[]))
|
||||
{
|
||||
// byte[]
|
||||
itemValue = Convert.FromBase64String(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))
|
||||
{
|
||||
stringValue = null;
|
||||
}
|
||||
else if (valueType == typeof(object))
|
||||
{
|
||||
throw new ArgumentException($"Cannot serialize the configuration item [{Scope}].[{Key}] which has the type [System.Object]", "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 if (valueType.IsGenericType &&
|
||||
valueType.GetGenericTypeDefinition() == typeof(Nullable<>) &&
|
||||
IsConvertableFromString(Nullable.GetUnderlyingType(valueType)))
|
||||
{
|
||||
// nullable
|
||||
stringValue = Value.ToString();
|
||||
}
|
||||
else if (valueType == typeof(Guid) || valueType == typeof(Guid?))
|
||||
{
|
||||
stringValue = Value.ToString();
|
||||
}
|
||||
else if (Value is byte[] valueBytes)
|
||||
{
|
||||
// byte[]
|
||||
stringValue = Convert.ToBase64String(valueBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
// JSON Serialize
|
||||
stringValue = JsonConvert.SerializeObject(Value);
|
||||
}
|
||||
|
||||
CacheSetItem(Database, Scope, Key, stringValue, Value);
|
||||
CacheSetItem(Database, Scope, Key, stringValue, Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cache Helpers
|
||||
@@ -293,8 +334,7 @@ namespace Disco.Data.Configuration
|
||||
{
|
||||
var cache = Cache(Database);
|
||||
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
if (cache.TryGetValue(Scope, out scopeCache))
|
||||
if (cache.TryGetValue(Scope, out var scopeCache))
|
||||
{
|
||||
return scopeCache.Keys.ToList();
|
||||
}
|
||||
@@ -318,8 +358,7 @@ namespace Disco.Data.Configuration
|
||||
// Remove item from Cache
|
||||
if (cacheStore != null)
|
||||
{
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
cacheStore.TryRemove(Scope, out scopeCache);
|
||||
cacheStore.TryRemove(Scope, out var scopeCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -359,10 +398,9 @@ namespace Disco.Data.Configuration
|
||||
// Remove item from Cache
|
||||
if (cacheItem != null)
|
||||
{
|
||||
ConfigurationCacheScopeType scopeCache;
|
||||
if (cacheStore.TryGetValue(Scope, out scopeCache))
|
||||
if (cacheStore.TryGetValue(Scope, out var scopeCache))
|
||||
{
|
||||
scopeCache.TryRemove(Key, out cacheItem);
|
||||
scopeCache.TryRemove(Key, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,37 @@ 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)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Disco.Data.Repository;
|
||||
using System;
|
||||
|
||||
namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
@@ -6,33 +7,24 @@ namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public BootstrapperConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||
|
||||
public override string Scope
|
||||
{
|
||||
get { return "Bootstrapper"; }
|
||||
}
|
||||
public override string Scope { get; } = "Bootstrapper";
|
||||
|
||||
public string MacSshUsername
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Get("root");
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Set(value);
|
||||
}
|
||||
get => Get("root");
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
public string MacSshPassword
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetDeobsfucated(string.Empty);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.SetObsfucated(value);
|
||||
}
|
||||
get => GetDeobsfucated(string.Empty);
|
||||
set => SetObsfucated(value);
|
||||
}
|
||||
|
||||
public TimeSpan PendingTimeout
|
||||
{
|
||||
get => TimeSpan.FromSeconds(Get(30 * 60)); // 30 minutes default
|
||||
set => Set((int)value.TotalSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Services.Devices.DeviceFlag;
|
||||
|
||||
namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public class DeviceFlagsConfiguration : ConfigurationBase
|
||||
{
|
||||
public DeviceFlagsConfiguration(DiscoDataContext database) : base(database) { }
|
||||
|
||||
public override string Scope { get; } = "DeviceFlags";
|
||||
|
||||
public DeviceFlagExportOptions LastExportOptions
|
||||
{
|
||||
get => Get(DeviceFlagExportOptions.DefaultOptions());
|
||||
set => Set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,13 @@ namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public DeviceProfilesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||
|
||||
public override string Scope { get { return "DeviceProfiles"; } }
|
||||
public override string Scope { get; } = "DeviceProfiles";
|
||||
|
||||
public int DefaultDeviceProfileId
|
||||
{
|
||||
get
|
||||
{
|
||||
var v = this.Get(1);
|
||||
var v = Get(1);
|
||||
if (v > 0)
|
||||
return v;
|
||||
else
|
||||
@@ -24,21 +24,21 @@ namespace Disco.Data.Configuration.Modules
|
||||
if (value < 1)
|
||||
throw new ArgumentOutOfRangeException("value", "Expected >= 1");
|
||||
|
||||
this.Set(value);
|
||||
Set(value);
|
||||
}
|
||||
}
|
||||
public int DefaultAddDeviceOfflineDeviceProfileId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Get(0);
|
||||
return Get(0);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentOutOfRangeException("value", "Expected >= 0");
|
||||
|
||||
this.Set(value);
|
||||
Set(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Services.Devices.Exporting;
|
||||
using Disco.Models.Services.Devices;
|
||||
|
||||
namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
@@ -7,12 +7,12 @@ namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public DevicesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||
|
||||
public override string Scope { get { return "Devices"; } }
|
||||
public override string Scope { get; } = "Devices";
|
||||
|
||||
public DeviceExportOptions LastExportOptions
|
||||
{
|
||||
get { return this.Get<DeviceExportOptions>(DeviceExportOptions.DefaultOptions()); }
|
||||
set { this.Set(value); }
|
||||
get => Get(DeviceExportOptions.DefaultOptions());
|
||||
set => Set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,18 @@ namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public DocumentsConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||
|
||||
public override string Scope { get { return "Documents"; } }
|
||||
public override string Scope { get; } = "Documents";
|
||||
|
||||
public List<DocumentTemplatePackage> Packages
|
||||
{
|
||||
get { return Get<List<DocumentTemplatePackage>>(null); }
|
||||
set { Set(value); }
|
||||
}
|
||||
|
||||
public DocumentExportOptions LastExportOptions
|
||||
{
|
||||
get => Get(DocumentExportOptions.DefaultOptions());
|
||||
set => Set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Services.Job;
|
||||
using Disco.Models.Services.Jobs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -9,18 +9,27 @@ namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public JobPreferencesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||
|
||||
public override string Scope { get { return "JobPreferences"; } }
|
||||
public override string Scope { get; } = "JobPreferences";
|
||||
|
||||
/// <summary>
|
||||
/// Initial comments template for new jobs
|
||||
/// </summary>
|
||||
public string InitialCommentsTemplate
|
||||
{
|
||||
get => Get<string>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of days a job is open before it is considered 'Long Running'
|
||||
/// </summary>
|
||||
public int LongRunningJobDaysThreshold
|
||||
{
|
||||
get { return Get<int>(7); }
|
||||
get => Get(7);
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentOutOfRangeException("value", "The Long Running Job Days Threshold cannot be less than zero");
|
||||
throw new ArgumentOutOfRangeException(nameof(value), "The Long Running Job Days Threshold cannot be less than zero");
|
||||
|
||||
Set(value);
|
||||
}
|
||||
@@ -31,27 +40,33 @@ namespace Disco.Data.Configuration.Modules
|
||||
/// </summary>
|
||||
public int StaleJobMinutesThreshold
|
||||
{
|
||||
get { return Get<int>(60 * 24 * 2); } // Default to 48 Hours (2 days)
|
||||
get => Get(60 * 24 * 2); // Default to 48 Hours (2 days)
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentOutOfRangeException("value", "The Stale Job Minutes Threshold cannot be less than zero");
|
||||
throw new ArgumentOutOfRangeException(nameof(value), "The Stale Job Minutes Threshold cannot be less than zero");
|
||||
|
||||
Set(value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool LodgmentIncludeAllAttachmentsByDefault
|
||||
{
|
||||
get => Get(false);
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Theme used in noticeboards by default.
|
||||
/// <see cref="Disco.Services.Extensions.UIHelpers.NoticeboardThemes"/>
|
||||
/// </summary>
|
||||
public string DefaultNoticeboardTheme
|
||||
{
|
||||
get { return Get("default"); }
|
||||
get => Get("default");
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
throw new ArgumentNullException("DefaultNoticeboardTheme");
|
||||
throw new ArgumentNullException(nameof(DefaultNoticeboardTheme));
|
||||
|
||||
Set(value);
|
||||
}
|
||||
@@ -59,26 +74,48 @@ namespace Disco.Data.Configuration.Modules
|
||||
|
||||
public LocationModes LocationMode
|
||||
{
|
||||
get { return Get(LocationModes.Unrestricted); }
|
||||
set { Set(value); }
|
||||
get => Get(LocationModes.Unrestricted);
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
public List<string> LocationList
|
||||
{
|
||||
get { return Get(new List<string>()); }
|
||||
set { Set(value); }
|
||||
get => Get(new List<string>());
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
public string OnCreateExpression
|
||||
{
|
||||
get { return Get<string>(null); }
|
||||
set { Set(value); }
|
||||
get => Get<string>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
public string OnDeviceReadyForReturnExpression
|
||||
{
|
||||
get => Get<string>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
public string OnCloseExpression
|
||||
{
|
||||
get { return Get<string>(null); }
|
||||
set { Set(value); }
|
||||
get => Get<string>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
public JobExportOptions LastExportOptions
|
||||
{
|
||||
get => Get(JobExportOptions.DefaultOptions());
|
||||
set
|
||||
{
|
||||
Set(value);
|
||||
LastExportDate = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? LastExportDate
|
||||
{
|
||||
get => Get<DateTime?>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.BI.Config;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -8,11 +7,9 @@ namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public class OrganisationAddressesConfiguration : ConfigurationBase
|
||||
{
|
||||
private const string scope = "OrganisationAddresses";
|
||||
|
||||
public OrganisationAddressesConfiguration(DiscoDataContext Database) : base(Database) { }
|
||||
|
||||
public override string Scope { get { return scope; } }
|
||||
public override string Scope { get; } = "OrganisationAddresses";
|
||||
|
||||
public OrganisationAddress GetAddress(int Id)
|
||||
{
|
||||
@@ -58,19 +55,5 @@ namespace Disco.Data.Configuration.Modules
|
||||
}
|
||||
}
|
||||
|
||||
internal static void MigrateDatabase(DiscoDataContext Database)
|
||||
{
|
||||
// Migrate all organisation addresses to JSON
|
||||
if (Database.ConfigurationItems.Count(i => i.Scope == scope && !i.Value.StartsWith("{")) > 0)
|
||||
{
|
||||
var items = Database.ConfigurationItems.Where(i => i.Scope == scope && !i.Value.StartsWith("{")).ToList();
|
||||
items.ForEach(i =>
|
||||
{
|
||||
i.Value = JsonConvert.SerializeObject(OrganisationAddress.FromConfigurationEntry(int.Parse(i.Key), i.Value));
|
||||
});
|
||||
Database.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Services.Users.UserFlags;
|
||||
|
||||
namespace Disco.Data.Configuration.Modules
|
||||
{
|
||||
public class UserFlagsConfiguration : ConfigurationBase
|
||||
{
|
||||
public UserFlagsConfiguration(DiscoDataContext database) : base(database) { }
|
||||
|
||||
public override string Scope { get; } = "UserFlags";
|
||||
|
||||
public UserFlagExportOptions LastExportOptions
|
||||
{
|
||||
get => Get(UserFlagExportOptions.DefaultOptions());
|
||||
set => Set(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Services.Exporting;
|
||||
using Disco.Models.Services.Interop.DiscoServices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Data.Configuration
|
||||
@@ -18,6 +20,8 @@ namespace Disco.Data.Configuration
|
||||
moduleActiveDirectoryConfiguration = new Lazy<Modules.ActiveDirectoryConfiguration>(() => new Modules.ActiveDirectoryConfiguration(Database));
|
||||
moduleDevicesConfiguration = new Lazy<Modules.DevicesConfiguration>(() => new Modules.DevicesConfiguration(Database));
|
||||
moduleDocumentsConfiguration = new Lazy<Modules.DocumentsConfiguration>(() => new Modules.DocumentsConfiguration(Database));
|
||||
moduleUserFlagsConfiguration = new Lazy<Modules.UserFlagsConfiguration>(() => new Modules.UserFlagsConfiguration(Database));
|
||||
moduleDeviceFlagsConfiguration = new Lazy<Modules.DeviceFlagsConfiguration>(() => new Modules.DeviceFlagsConfiguration(Database));
|
||||
}
|
||||
|
||||
#region Configuration Modules
|
||||
@@ -29,61 +33,22 @@ namespace Disco.Data.Configuration
|
||||
private Lazy<Modules.ActiveDirectoryConfiguration> moduleActiveDirectoryConfiguration;
|
||||
private Lazy<Modules.DevicesConfiguration> moduleDevicesConfiguration;
|
||||
private Lazy<Modules.DocumentsConfiguration> moduleDocumentsConfiguration;
|
||||
private Lazy<Modules.UserFlagsConfiguration> moduleUserFlagsConfiguration;
|
||||
private Lazy<Modules.DeviceFlagsConfiguration> moduleDeviceFlagsConfiguration;
|
||||
|
||||
public Modules.BootstrapperConfiguration Bootstrapper
|
||||
{
|
||||
get
|
||||
{
|
||||
return moduleBootstrapperConfiguration.Value;
|
||||
}
|
||||
}
|
||||
public Modules.DeviceProfilesConfiguration DeviceProfiles
|
||||
{
|
||||
get
|
||||
{
|
||||
return moduleDeviceProfilesConfiguration.Value;
|
||||
}
|
||||
}
|
||||
public Modules.OrganisationAddressesConfiguration OrganisationAddresses
|
||||
{
|
||||
get
|
||||
{
|
||||
return moduleOrganisationAddressesConfiguration.Value;
|
||||
}
|
||||
}
|
||||
public Modules.JobPreferencesConfiguration JobPreferences
|
||||
{
|
||||
get
|
||||
{
|
||||
return moduleJobPreferencesConfiguration.Value;
|
||||
}
|
||||
}
|
||||
public Modules.ActiveDirectoryConfiguration ActiveDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return moduleActiveDirectoryConfiguration.Value;
|
||||
}
|
||||
}
|
||||
public Modules.DevicesConfiguration Devices
|
||||
{
|
||||
get
|
||||
{
|
||||
return moduleDevicesConfiguration.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public Modules.DocumentsConfiguration Documents
|
||||
{
|
||||
get
|
||||
{
|
||||
return moduleDocumentsConfiguration.Value;
|
||||
}
|
||||
}
|
||||
public Modules.BootstrapperConfiguration Bootstrapper => moduleBootstrapperConfiguration.Value;
|
||||
public Modules.DeviceProfilesConfiguration DeviceProfiles => moduleDeviceProfilesConfiguration.Value;
|
||||
public Modules.OrganisationAddressesConfiguration OrganisationAddresses => moduleOrganisationAddressesConfiguration.Value;
|
||||
public Modules.JobPreferencesConfiguration JobPreferences => moduleJobPreferencesConfiguration.Value;
|
||||
public Modules.ActiveDirectoryConfiguration ActiveDirectory => moduleActiveDirectoryConfiguration.Value;
|
||||
public Modules.DevicesConfiguration Devices => moduleDevicesConfiguration.Value;
|
||||
public Modules.DocumentsConfiguration Documents => moduleDocumentsConfiguration.Value;
|
||||
public Modules.UserFlagsConfiguration UserFlags => moduleUserFlagsConfiguration.Value;
|
||||
public Modules.DeviceFlagsConfiguration DeviceFlags => moduleDeviceFlagsConfiguration.Value;
|
||||
|
||||
#endregion
|
||||
|
||||
public override string Scope { get { return "System"; } }
|
||||
public override string Scope { get; } = "System";
|
||||
|
||||
public string DataStoreLocation
|
||||
{
|
||||
@@ -93,26 +58,27 @@ namespace Disco.Data.Configuration
|
||||
if (result == null)
|
||||
{
|
||||
var appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");
|
||||
if (appDataPath.EndsWith("\\"))
|
||||
return appDataPath;
|
||||
else
|
||||
return string.Concat(appDataPath, '\\');
|
||||
|
||||
if (!appDataPath.EndsWith(@"\"))
|
||||
appDataPath += @"\";
|
||||
|
||||
return appDataPath;
|
||||
}
|
||||
else
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
if (!System.IO.Directory.Exists(value))
|
||||
throw new System.IO.DirectoryNotFoundException(string.Format("DataStoreLocation: '{0}' could not be found", value));
|
||||
string storePath;
|
||||
if (value.EndsWith("\\"))
|
||||
storePath = value;
|
||||
else
|
||||
storePath = string.Concat(value, '\\');
|
||||
Set(storePath);
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
|
||||
if (!Directory.Exists(value))
|
||||
throw new DirectoryNotFoundException($"DataStoreLocation: '{value}' could not be found");
|
||||
|
||||
if (!value.EndsWith(@"\"))
|
||||
value += @"\";
|
||||
|
||||
Set(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,26 +95,15 @@ namespace Disco.Data.Configuration
|
||||
}
|
||||
|
||||
#region Plugin Locations
|
||||
public string PluginsLocation
|
||||
public string PluginsLocation => Path.Combine(DataStoreLocation, @"Plugins\");
|
||||
public string PluginStorageLocation => Path.Combine(DataStoreLocation, @"PluginStorage\");
|
||||
public string PluginPackagesLocation => Path.Combine(DataStoreLocation, @"PluginPackages\");
|
||||
public string PluginUserPhotosLocation => Path.Combine(DataStoreLocation, @"PluginUserPhotos\");
|
||||
|
||||
public DateTime PluginDetailsCacheExpiration
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.IO.Path.Combine(DataStoreLocation, @"Plugins\");
|
||||
}
|
||||
}
|
||||
public string PluginStorageLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.IO.Path.Combine(DataStoreLocation, @"PluginStorage\");
|
||||
}
|
||||
}
|
||||
public string PluginPackagesLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.IO.Path.Combine(DataStoreLocation, @"PluginPackages\");
|
||||
}
|
||||
get => Get(DateTime.MinValue);
|
||||
set => Set(value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -158,7 +113,7 @@ namespace Disco.Data.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.IO.Path.Combine(DataStoreLocation, "OrganisationLogo.png");
|
||||
return Path.Combine(DataStoreLocation, "OrganisationLogo.png");
|
||||
}
|
||||
}
|
||||
public string OrganisationLogoHash
|
||||
@@ -180,15 +135,15 @@ namespace Disco.Data.Configuration
|
||||
if (File.Exists(path))
|
||||
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
else
|
||||
return new MemoryStream(Disco.Data.Properties.Resources.EmptyLogo);
|
||||
return new MemoryStream(Properties.Resources.EmptyLogo);
|
||||
}
|
||||
set
|
||||
{
|
||||
string organisationLogoPath = OrganisationLogoPath;
|
||||
if (value == null)
|
||||
{
|
||||
if (System.IO.File.Exists(organisationLogoPath))
|
||||
System.IO.File.Delete(organisationLogoPath);
|
||||
if (File.Exists(organisationLogoPath))
|
||||
File.Delete(organisationLogoPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -271,21 +226,89 @@ 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
|
||||
public bool IsActivated => ActivationId.HasValue;
|
||||
|
||||
public DateTime? ActivatedOn
|
||||
{
|
||||
get
|
||||
{
|
||||
return Get<string>(null);
|
||||
}
|
||||
get => Get((DateTime?)null);
|
||||
set => Set(value);
|
||||
}
|
||||
public string DeploymentSecret
|
||||
public string ActivatedBy
|
||||
{
|
||||
get
|
||||
{
|
||||
return Get<string>(null);
|
||||
}
|
||||
get => Get((string)null);
|
||||
set => Set(value);
|
||||
}
|
||||
public Guid? ActivationId
|
||||
{
|
||||
get => Get((Guid?)null);
|
||||
set => Set(value);
|
||||
}
|
||||
public byte[] ActivationKey
|
||||
{
|
||||
get => Get((byte[])null);
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
public bool IsLicensed
|
||||
{
|
||||
get => LicenseKey != null && LicenseExpiresOn != null && LicenseExpiresOn > DateTime.UtcNow && LicenseError == null;
|
||||
}
|
||||
public string LicenseKey
|
||||
{
|
||||
get => Get<string>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
public DateTime? LicenseExpiresOn
|
||||
{
|
||||
get => Get<DateTime?>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
public string LicenseError
|
||||
{
|
||||
get => Get<string>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
public string DeploymentId => Get<string>(null);
|
||||
public string DeploymentSecret => Get<string>(null);
|
||||
public short DeploymentChecksum
|
||||
{
|
||||
get
|
||||
@@ -304,22 +327,10 @@ namespace Disco.Data.Configuration
|
||||
}
|
||||
public UpdateResponseV2 UpdateLastCheckResponse
|
||||
{
|
||||
get
|
||||
{
|
||||
return Get<UpdateResponseV2>(null);
|
||||
}
|
||||
set
|
||||
{
|
||||
Set(value);
|
||||
}
|
||||
}
|
||||
public bool UpdateBetaDeployment
|
||||
{
|
||||
get
|
||||
{
|
||||
return Get(false);
|
||||
}
|
||||
get => Get<UpdateResponseV2>(null);
|
||||
set => Set(value);
|
||||
}
|
||||
public bool UpdateBetaDeployment => Get(false);
|
||||
public Version InstalledDatabaseVersion
|
||||
{
|
||||
get
|
||||
@@ -337,5 +348,11 @@ namespace Disco.Data.Configuration
|
||||
}
|
||||
#endregion
|
||||
|
||||
public List<SavedExport> SavedExports
|
||||
{
|
||||
get => Get(new List<SavedExport>());
|
||||
set => Set(value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Disco.Data</RootNamespace>
|
||||
<AssemblyName>Disco.Data</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
@@ -40,8 +40,8 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
@@ -77,6 +77,8 @@
|
||||
<Compile Include="Configuration\ConfigurationCache.cs" />
|
||||
<Compile Include="Configuration\Modules\ActiveDirectoryConfiguration.cs" />
|
||||
<Compile Include="Configuration\Modules\DevicesConfiguration.cs" />
|
||||
<Compile Include="Configuration\Modules\DeviceFlagsConfiguration.cs" />
|
||||
<Compile Include="Configuration\Modules\UserFlagsConfiguration.cs" />
|
||||
<Compile Include="Configuration\Modules\DocumentsConfiguration.cs" />
|
||||
<Compile Include="Configuration\Modules\JobPreferencesConfiguration.cs" />
|
||||
<Compile Include="Configuration\SystemConfiguration.cs" />
|
||||
@@ -163,6 +165,50 @@
|
||||
<Compile Include="Migrations\201611100557315_DBv19.Designer.cs">
|
||||
<DependentUpon>201611100557315_DBv19.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202011260525547_DBv20.cs" />
|
||||
<Compile Include="Migrations\202011260525547_DBv20.Designer.cs">
|
||||
<DependentUpon>202011260525547_DBv20.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202102110443550_DBv21.cs" />
|
||||
<Compile Include="Migrations\202102110443550_DBv21.Designer.cs">
|
||||
<DependentUpon>202102110443550_DBv21.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202304150715559_DBv22.cs" />
|
||||
<Compile Include="Migrations\202304150715559_DBv22.Designer.cs">
|
||||
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202401130531317_DBv23.cs" />
|
||||
<Compile Include="Migrations\202401130531317_DBv23.Designer.cs">
|
||||
<DependentUpon>202401130531317_DBv23.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202403030134280_DBv24.cs" />
|
||||
<Compile Include="Migrations\202403030134280_DBv24.Designer.cs">
|
||||
<DependentUpon>202403030134280_DBv24.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202412180604170_DBv25.cs" />
|
||||
<Compile Include="Migrations\202412180604170_DBv25.Designer.cs">
|
||||
<DependentUpon>202412180604170_DBv25.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202503140520548_DBv26.cs" />
|
||||
<Compile Include="Migrations\202503140520548_DBv26.Designer.cs">
|
||||
<DependentUpon>202503140520548_DBv26.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202507110430252_DBv27.cs" />
|
||||
<Compile Include="Migrations\202507110430252_DBv27.Designer.cs">
|
||||
<DependentUpon>202507110430252_DBv27.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202507170522576_DBv28.cs" />
|
||||
<Compile Include="Migrations\202507170522576_DBv28.Designer.cs">
|
||||
<DependentUpon>202507170522576_DBv28.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202509070209304_DBv29.cs" />
|
||||
<Compile Include="Migrations\202509070209304_DBv29.Designer.cs">
|
||||
<DependentUpon>202509070209304_DBv29.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\202509180416385_DBv30.cs" />
|
||||
<Compile Include="Migrations\202509180416385_DBv30.Designer.cs">
|
||||
<DependentUpon>202509180416385_DBv30.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\Configuration.cs" />
|
||||
<Compile Include="Migrations\DiscoDataMigrator.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -235,6 +281,39 @@
|
||||
<EmbeddedResource Include="Migrations\201611100557315_DBv19.resx">
|
||||
<DependentUpon>201611100557315_DBv19.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202011260525547_DBv20.resx">
|
||||
<DependentUpon>202011260525547_DBv20.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202102110443550_DBv21.resx">
|
||||
<DependentUpon>202102110443550_DBv21.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202304150715559_DBv22.resx">
|
||||
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202401130531317_DBv23.resx">
|
||||
<DependentUpon>202401130531317_DBv23.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202403030134280_DBv24.resx">
|
||||
<DependentUpon>202403030134280_DBv24.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202412180604170_DBv25.resx">
|
||||
<DependentUpon>202412180604170_DBv25.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202503140520548_DBv26.resx">
|
||||
<DependentUpon>202503140520548_DBv26.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202507110430252_DBv27.resx">
|
||||
<DependentUpon>202507110430252_DBv27.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202507170522576_DBv28.resx">
|
||||
<DependentUpon>202507170522576_DBv28.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202509070209304_DBv29.resx">
|
||||
<DependentUpon>202509070209304_DBv29.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\202509180416385_DBv30.resx">
|
||||
<DependentUpon>202509180416385_DBv30.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
@@ -246,6 +325,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">
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,27 @@
|
||||
// <auto-generated />
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using System.Resources;
|
||||
|
||||
public sealed partial class DBv23 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv23));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202401130531317_DBv23"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class DBv23 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
CreateTable(
|
||||
"dbo.DeviceFlagAssignments",
|
||||
c => new
|
||||
{
|
||||
Id = c.Int(nullable: false, identity: true),
|
||||
DeviceFlagId = c.Int(nullable: false),
|
||||
DeviceSerialNumber = c.String(nullable: false, maxLength: 60),
|
||||
AddedDate = c.DateTime(nullable: false),
|
||||
AddedUserId = c.String(nullable: false, maxLength: 50),
|
||||
RemovedDate = c.DateTime(),
|
||||
RemovedUserId = c.String(maxLength: 50),
|
||||
Comments = c.String(),
|
||||
OnAssignmentExpressionResult = c.String(),
|
||||
OnUnassignmentExpressionResult = c.String(),
|
||||
})
|
||||
.PrimaryKey(t => t.Id)
|
||||
.ForeignKey("dbo.DeviceFlags", t => t.DeviceFlagId)
|
||||
.ForeignKey("dbo.Devices", t => t.DeviceSerialNumber)
|
||||
.ForeignKey("dbo.Users", t => t.AddedUserId)
|
||||
.ForeignKey("dbo.Users", t => t.RemovedUserId)
|
||||
.Index(t => t.DeviceFlagId)
|
||||
.Index(t => t.DeviceSerialNumber)
|
||||
.Index(t => t.AddedUserId)
|
||||
.Index(t => t.RemovedUserId);
|
||||
|
||||
CreateTable(
|
||||
"dbo.DeviceFlags",
|
||||
c => new
|
||||
{
|
||||
Id = c.Int(nullable: false, identity: true),
|
||||
Name = c.String(nullable: false, maxLength: 100),
|
||||
Description = c.String(maxLength: 500),
|
||||
Icon = c.String(nullable: false, maxLength: 25),
|
||||
IconColour = c.String(nullable: false, maxLength: 10),
|
||||
DevicesLinkedGroup = c.String(),
|
||||
DeviceUsersLinkedGroup = c.String(),
|
||||
OnAssignmentExpression = c.String(),
|
||||
OnUnassignmentExpression = c.String(),
|
||||
})
|
||||
.PrimaryKey(t => t.Id);
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropIndex("dbo.DeviceFlagAssignments", new[] { "RemovedUserId" });
|
||||
DropIndex("dbo.DeviceFlagAssignments", new[] { "AddedUserId" });
|
||||
DropIndex("dbo.DeviceFlagAssignments", new[] { "DeviceSerialNumber" });
|
||||
DropIndex("dbo.DeviceFlagAssignments", new[] { "DeviceFlagId" });
|
||||
DropForeignKey("dbo.DeviceFlagAssignments", "RemovedUserId", "dbo.Users");
|
||||
DropForeignKey("dbo.DeviceFlagAssignments", "AddedUserId", "dbo.Users");
|
||||
DropForeignKey("dbo.DeviceFlagAssignments", "DeviceSerialNumber", "dbo.Devices");
|
||||
DropForeignKey("dbo.DeviceFlagAssignments", "DeviceFlagId", "dbo.DeviceFlags");
|
||||
DropTable("dbo.DeviceFlags");
|
||||
DropTable("dbo.DeviceFlagAssignments");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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 DBv24 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv24));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202403030134280_DBv24"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class DBv24 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
AddColumn("dbo.JobMetaInsurances", "Insurer", c => c.String(maxLength: 200));
|
||||
AddColumn("dbo.JobMetaInsurances", "InsurerReference", c => c.String(maxLength: 200));
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropColumn("dbo.JobMetaInsurances", "InsurerReference");
|
||||
DropColumn("dbo.JobMetaInsurances", "Insurer");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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 DBv25 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv25));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202412180604170_DBv25"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class DBv25 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
AlterColumn("dbo.UserAttachments", "Comments", c => c.String(maxLength: 500));
|
||||
AlterColumn("dbo.JobAttachments", "Comments", c => c.String(maxLength: 500));
|
||||
AlterColumn("dbo.DeviceAttachments", "Comments", c => c.String(maxLength: 500));
|
||||
|
||||
Sql("DELETE [dbo].[Configuration] WHERE [Scope]='System' AND [Key] IN ('ActivatedOn', 'ActivationId', 'LicenseExpiresOn')");
|
||||
Sql("DELETE [dbo].[Configuration] WHERE [Scope]='DocFill' AND [Key] IN ('LicenseExpiresOn')");
|
||||
Sql("DELETE [dbo].[Configuration] WHERE [Scope]='JobPreferences' AND [Key] IN ('LastExportDate')");
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
AlterColumn("dbo.DeviceAttachments", "Comments", c => c.String(nullable: false, maxLength: 500));
|
||||
AlterColumn("dbo.JobAttachments", "Comments", c => c.String(nullable: false, maxLength: 500));
|
||||
AlterColumn("dbo.UserAttachments", "Comments", c => c.String(nullable: false, maxLength: 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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 DBv26 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv26));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202503140520548_DBv26"; }
|
||||
}
|
||||
|
||||
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 DBv26 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
AlterColumn("dbo.DeviceBatchAttachments", "Comments", c => c.String(maxLength: 500));
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
AlterColumn("dbo.DeviceBatchAttachments", "Comments", c => c.String(nullable: false, maxLength: 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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 DBv27 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv27));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202507110430252_DBv27"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class DBv27 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
CreateTable(
|
||||
"dbo.UserComments",
|
||||
c => new
|
||||
{
|
||||
Id = c.Int(nullable: false, identity: true),
|
||||
UserId = c.String(maxLength: 50),
|
||||
TechUserId = c.String(nullable: false, maxLength: 50),
|
||||
Timestamp = c.DateTime(nullable: false),
|
||||
Comments = c.String(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.Id)
|
||||
.ForeignKey("dbo.Users", t => t.TechUserId)
|
||||
.ForeignKey("dbo.Users", t => t.UserId)
|
||||
.Index(t => t.TechUserId)
|
||||
.Index(t => t.UserId);
|
||||
|
||||
CreateTable(
|
||||
"dbo.DeviceComments",
|
||||
c => new
|
||||
{
|
||||
Id = c.Int(nullable: false, identity: true),
|
||||
DeviceSerialNumber = c.String(maxLength: 60),
|
||||
TechUserId = c.String(nullable: false, maxLength: 50),
|
||||
Timestamp = c.DateTime(nullable: false),
|
||||
Comments = c.String(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.Id)
|
||||
.ForeignKey("dbo.Users", t => t.TechUserId)
|
||||
.ForeignKey("dbo.Devices", t => t.DeviceSerialNumber)
|
||||
.Index(t => t.TechUserId)
|
||||
.Index(t => t.DeviceSerialNumber);
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropIndex("dbo.DeviceComments", new[] { "DeviceSerialNumber" });
|
||||
DropIndex("dbo.DeviceComments", new[] { "TechUserId" });
|
||||
DropIndex("dbo.UserComments", new[] { "UserId" });
|
||||
DropIndex("dbo.UserComments", new[] { "TechUserId" });
|
||||
DropForeignKey("dbo.DeviceComments", "DeviceSerialNumber", "dbo.Devices");
|
||||
DropForeignKey("dbo.DeviceComments", "TechUserId", "dbo.Users");
|
||||
DropForeignKey("dbo.UserComments", "UserId", "dbo.Users");
|
||||
DropForeignKey("dbo.UserComments", "TechUserId", "dbo.Users");
|
||||
DropTable("dbo.DeviceComments");
|
||||
DropTable("dbo.UserComments");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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 DBv28 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv28));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202507170522576_DBv28"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class DBv28 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
AddColumn("dbo.UserFlagAssignments", "RemoveDate", c => c.DateTime());
|
||||
AddColumn("dbo.UserFlagAssignments", "RemoveUserId", c => c.String(maxLength: 50));
|
||||
AddColumn("dbo.UserFlags", "Permissions", c => c.String());
|
||||
AddColumn("dbo.UserFlags", "DefaultRemoveDays", c => c.Int());
|
||||
AddColumn("dbo.DeviceFlagAssignments", "RemoveDate", c => c.DateTime());
|
||||
AddColumn("dbo.DeviceFlagAssignments", "RemoveUserId", c => c.String(maxLength: 50));
|
||||
AddColumn("dbo.DeviceFlags", "Permissions", c => c.String());
|
||||
AddColumn("dbo.DeviceFlags", "DefaultRemoveDays", c => c.Int());
|
||||
AddForeignKey("dbo.UserFlagAssignments", "RemoveUserId", "dbo.Users", "Id");
|
||||
AddForeignKey("dbo.DeviceFlagAssignments", "RemoveUserId", "dbo.Users", "Id");
|
||||
CreateIndex("dbo.UserFlagAssignments", "RemoveUserId");
|
||||
CreateIndex("dbo.DeviceFlagAssignments", "RemoveUserId");
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropIndex("dbo.DeviceFlagAssignments", new[] { "RemoveUserId" });
|
||||
DropIndex("dbo.UserFlagAssignments", new[] { "RemoveUserId" });
|
||||
DropForeignKey("dbo.DeviceFlagAssignments", "RemoveUserId", "dbo.Users");
|
||||
DropForeignKey("dbo.UserFlagAssignments", "RemoveUserId", "dbo.Users");
|
||||
DropColumn("dbo.DeviceFlags", "DefaultRemoveDays");
|
||||
DropColumn("dbo.DeviceFlags", "Permissions");
|
||||
DropColumn("dbo.DeviceFlagAssignments", "RemoveUserId");
|
||||
DropColumn("dbo.DeviceFlagAssignments", "RemoveDate");
|
||||
DropColumn("dbo.UserFlags", "DefaultRemoveDays");
|
||||
DropColumn("dbo.UserFlags", "Permissions");
|
||||
DropColumn("dbo.UserFlagAssignments", "RemoveUserId");
|
||||
DropColumn("dbo.UserFlagAssignments", "RemoveDate");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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 DBv29 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv29));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202509070209304_DBv29"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class DBv29 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
AddColumn("dbo.DeviceProfiles", "SetAssignedUserForLogon", c => c.Boolean(nullable: false));
|
||||
Sql("UPDATE dbo.DeviceProfiles SET SetAssignedUserForLogon = 1");
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropColumn("dbo.DeviceProfiles", "SetAssignedUserForLogon");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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 DBv30 : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv30));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "202509180416385_DBv30"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class DBv30 : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
AddColumn("dbo.DeviceProfiles", "ProvisionFromOtherDomain", c => c.Boolean(nullable: false, defaultValue: false));
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropColumn("dbo.DeviceProfiles", "ProvisionFromOtherDomain");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,9 +1,6 @@
|
||||
namespace Disco.Data.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Linq;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
internal sealed class Configuration : DbMigrationsConfiguration<DiscoDataContext>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyFileVersion("2.2.16320.1300")]
|
||||
[assembly: AssemblyVersion("2.5.25262.0000")]
|
||||
[assembly: AssemblyFileVersion("2.5.25262.0000")]
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@@ -19,7 +19,7 @@ namespace Disco.Data.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using Disco.Models.Repository;
|
||||
using System.Data.Entity.ModelConfiguration.Conventions;
|
||||
|
||||
namespace Disco.Data.Repository
|
||||
@@ -14,7 +11,7 @@ namespace Disco.Data.Repository
|
||||
|
||||
public DiscoDataContext()
|
||||
{
|
||||
this._Configuration = new Lazy<Configuration.SystemConfiguration>(() => new Configuration.SystemConfiguration(this));
|
||||
_Configuration = new Lazy<Configuration.SystemConfiguration>(() => new Configuration.SystemConfiguration(this));
|
||||
}
|
||||
|
||||
public virtual DbSet<ConfigurationItem> ConfigurationItems { get; set; }
|
||||
@@ -22,6 +19,8 @@ namespace Disco.Data.Repository
|
||||
public virtual DbSet<DocumentTemplate> DocumentTemplates { get; set; }
|
||||
|
||||
public virtual DbSet<User> Users { get; set; }
|
||||
public virtual DbSet<UserComment> UserComments { 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; }
|
||||
@@ -30,12 +29,16 @@ namespace Disco.Data.Repository
|
||||
public virtual DbSet<DeviceUserAssignment> DeviceUserAssignments { get; set; }
|
||||
|
||||
public virtual DbSet<Device> Devices { get; set; }
|
||||
public virtual DbSet<DeviceComment> DeviceComments { get; set; }
|
||||
public virtual DbSet<DeviceDetail> DeviceDetails { get; set; }
|
||||
public virtual DbSet<DeviceModel> DeviceModels { get; set; }
|
||||
public virtual DbSet<DeviceProfile> DeviceProfiles { get; set; }
|
||||
public virtual DbSet<DeviceBatch> DeviceBatches { get; set; }
|
||||
public virtual DbSet<DeviceBatchAttachment> DeviceBatchAttachments { get; set; }
|
||||
public virtual DbSet<DeviceComponent> DeviceComponents { get; set; }
|
||||
public virtual DbSet<DeviceAttachment> DeviceAttachments { get; set; }
|
||||
public virtual DbSet<DeviceFlag> DeviceFlags { get; set; }
|
||||
public virtual DbSet<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
|
||||
|
||||
public virtual DbSet<DeviceCertificate> DeviceCertificates { get; set; }
|
||||
|
||||
@@ -57,7 +60,7 @@ namespace Disco.Data.Repository
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._Configuration.Value;
|
||||
return _Configuration.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Data.SqlClient;
|
||||
using System.DirectoryServices.ActiveDirectory;
|
||||
using System.DirectoryServices;
|
||||
using System.DirectoryServices.ActiveDirectory;
|
||||
using System.Linq;
|
||||
|
||||
namespace Disco.Data.Repository
|
||||
{
|
||||
@@ -22,8 +20,6 @@ namespace Disco.Data.Repository
|
||||
Database.SaveChanges();
|
||||
|
||||
// Migration Maintenance
|
||||
Database.MigrateConfiguration();
|
||||
|
||||
Database.MigratePreDomainObjects();
|
||||
}
|
||||
|
||||
@@ -62,7 +58,7 @@ namespace Disco.Data.Repository
|
||||
{
|
||||
if (Database.DeviceModels.Count() == 0)
|
||||
{
|
||||
Database.DeviceModels.Add(new DeviceModel { Manufacturer = "Unknown", Model = "Unknown", Description = "Unknown Device Model" });
|
||||
Database.DeviceModels.Add(new DeviceModel { Manufacturer = "Unknown", Model = "Unknown", Description = "Unknown Device Model", ModelType = "Unknown" });
|
||||
}
|
||||
UpdateDeviceModelConfiguration(Database);
|
||||
// Removed: 2013-01-14 G#
|
||||
@@ -212,6 +208,15 @@ namespace Disco.Data.Repository
|
||||
#endregion
|
||||
// End
|
||||
|
||||
// 2025-07-11
|
||||
#region "User Management - BYOD" Added
|
||||
if (Database.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.UMgmt && jst.Id == JobSubType.UserManagementJobSubTypes.BYOD) == 0)
|
||||
{
|
||||
Database.JobSubTypes.Add(new JobSubType { Id = JobSubType.UserManagementJobSubTypes.BYOD, JobTypeId = JobType.JobTypeIds.UMgmt, Description = JobSubType.UserManagementJobSubTypes.BYOD });
|
||||
}
|
||||
#endregion
|
||||
// End
|
||||
|
||||
// 2012-05-29 - Audits
|
||||
#region "Audit" Added
|
||||
if (Database.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.HMisc && jst.Id == "Audit") == 0)
|
||||
@@ -259,8 +264,7 @@ namespace Disco.Data.Repository
|
||||
foreach (var configurationItem in configurationItems)
|
||||
{
|
||||
int profileId = int.Parse(configurationItem.Scope.Substring(configurationItem.Scope.IndexOf(":") + 1));
|
||||
DeviceProfile dp;
|
||||
if (deviceProfiles.TryGetValue(profileId, out dp))
|
||||
if (deviceProfiles.TryGetValue(profileId, out var dp))
|
||||
{
|
||||
switch (configurationItem.Key)
|
||||
{
|
||||
@@ -268,7 +272,7 @@ namespace Disco.Data.Repository
|
||||
dp.ComputerNameTemplate = configurationItem.Value;
|
||||
break;
|
||||
case "DistributionType":
|
||||
dp.DistributionType = (DeviceProfile.DistributionTypes)(int.Parse(configurationItem.Value));
|
||||
dp.DistributionType = (DeviceProfile.DistributionTypes)int.Parse(configurationItem.Value);
|
||||
break;
|
||||
case "OrganisationalUnit":
|
||||
dp.OrganisationalUnit = configurationItem.Value;
|
||||
@@ -291,7 +295,7 @@ namespace Disco.Data.Repository
|
||||
private static void UpdateDeviceModelDuplicates(this DiscoDataContext Database)
|
||||
{
|
||||
var deviceModels = Database.DeviceModels.ToList();
|
||||
var duplicateModels = deviceModels.GroupBy(g => string.Format("{0}|{1}", g.Manufacturer, g.Model)).Where(g => g.Count() > 1);
|
||||
var duplicateModels = deviceModels.GroupBy(g => $"{g.Manufacturer}|{g.Model}").Where(g => g.Count() > 1);
|
||||
foreach (var duplicateModel in duplicateModels)
|
||||
{
|
||||
var primaryModel = duplicateModel.OrderBy(dm => dm.Id).First();
|
||||
@@ -305,23 +309,15 @@ namespace Disco.Data.Repository
|
||||
if (!redundantModel.Description.EndsWith("** REDUNDANT **"))
|
||||
{
|
||||
if (redundantModel.Description.Length > 484)
|
||||
redundantModel.Description = string.Format("{0} ** REDUNDANT **", redundantModel.Description.Substring(0, 484));
|
||||
redundantModel.Description = $"{redundantModel.Description.Substring(0, 484)} ** REDUNDANT **";
|
||||
else
|
||||
redundantModel.Description = string.Format("{0} ** REDUNDANT **", redundantModel.Description);
|
||||
redundantModel.Description = $"{redundantModel.Description} ** REDUNDANT **";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// End Added: 2013-02-07 G#
|
||||
|
||||
public static void MigrateConfiguration(this DiscoDataContext Database)
|
||||
{
|
||||
// Organisation Addresses - Force all to JSON serializing
|
||||
Configuration.Modules.OrganisationAddressesConfiguration.MigrateDatabase(Database);
|
||||
|
||||
Database.SaveChanges();
|
||||
}
|
||||
|
||||
#region Migrate Users SQL
|
||||
private const string MigratePreDomainUsers_Sql = @"INSERT INTO [Users] SELECT @IdNew, u.DisplayName, u.Surname, u.GivenName, u.PhoneNumber, u.EmailAddress FROM [Users] u WHERE [Id]=@IdExisting;
|
||||
|
||||
@@ -370,7 +366,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
|
||||
string defaultNamingContext;
|
||||
using (Domain d = Domain.GetComputerDomain())
|
||||
{
|
||||
string ldapPath = string.Format("LDAP://{0}/", d.Name);
|
||||
string ldapPath = $"LDAP://{d.Name}/";
|
||||
string configurationNamingContext;
|
||||
|
||||
using (var adRootDSE = new DirectoryEntry(ldapPath + "RootDSE"))
|
||||
@@ -381,7 +377,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
|
||||
|
||||
using (var configSearchRoot = new DirectoryEntry(ldapPath + "CN=Partitions," + configurationNamingContext))
|
||||
{
|
||||
var configSearchFilter = string.Format("(&(objectcategory=Crossref)(dnsRoot={0})(netBIOSName=*))", d.Name);
|
||||
var configSearchFilter = $"(&(objectcategory=Crossref)(dnsRoot={d.Name})(netBIOSName=*))";
|
||||
var configSearchLoadProperites = new string[] { "NetBIOSName" };
|
||||
|
||||
using (var configSearcher = new DirectorySearcher(configSearchRoot, configSearchFilter, configSearchLoadProperites, SearchScope.OneLevel))
|
||||
@@ -403,14 +399,14 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
|
||||
// Authorization Roles
|
||||
foreach (var authRole in Database.AuthorizationRoles.Where(ar => ar.SubjectIds != null).ToList())
|
||||
{
|
||||
var ids = string.Join(",", authRole.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : string.Format("{0}\\{1}", netBiosName, id)));
|
||||
var ids = string.Join(",", authRole.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : $@"{netBiosName}\{id}"));
|
||||
if (ids != authRole.SubjectIds)
|
||||
authRole.SubjectIds = ids;
|
||||
}
|
||||
// Job Queues
|
||||
foreach (var jobQueue in Database.JobQueues.Where(jq => jq.SubjectIds != null).ToList())
|
||||
{
|
||||
var ids = string.Join(",", jobQueue.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : string.Format("{0}\\{1}", netBiosName, id)));
|
||||
var ids = string.Join(",", jobQueue.SubjectIds.Split(',').Select(id => id.Contains('\\') ? id : $@"{netBiosName}\{id}"));
|
||||
if (ids != jobQueue.SubjectIds)
|
||||
jobQueue.SubjectIds = ids;
|
||||
}
|
||||
@@ -418,9 +414,9 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
|
||||
foreach (var deviceProfile in Database.DeviceProfiles.Where(dp => dp.OrganisationalUnit == null || !dp.OrganisationalUnit.Contains(@"DC=")).ToList())
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(deviceProfile.OrganisationalUnit))
|
||||
deviceProfile.OrganisationalUnit = string.Format("CN=Computers,{0}", defaultNamingContext);
|
||||
deviceProfile.OrganisationalUnit = $"CN=Computers,{defaultNamingContext}";
|
||||
else
|
||||
deviceProfile.OrganisationalUnit = string.Format("{0},{1}", deviceProfile.OrganisationalUnit, defaultNamingContext);
|
||||
deviceProfile.OrganisationalUnit = $"{deviceProfile.OrganisationalUnit},{defaultNamingContext}";
|
||||
}
|
||||
Database.SaveChanges();
|
||||
|
||||
@@ -428,7 +424,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
|
||||
var dataStoreLocation = Database.ConfigurationItems.Where(ci => ci.Scope == "System" && ci.Key == "DataStoreLocation").Select(ci => ci.Value).FirstOrDefault();
|
||||
if (!string.IsNullOrWhiteSpace(dataStoreLocation) && System.IO.Directory.Exists(dataStoreLocation))
|
||||
{
|
||||
string filePrefix = string.Format("{0}_", netBiosName);
|
||||
string filePrefix = $"{netBiosName}_";
|
||||
|
||||
var userAttachmentsDirectory = System.IO.Path.Combine(dataStoreLocation, "UserAttachments");
|
||||
if (System.IO.Directory.Exists(userAttachmentsDirectory))
|
||||
@@ -451,7 +447,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
|
||||
// MIGRATE DEVICES
|
||||
foreach (var device in Database.Devices.Where(d => d.DeviceDomainId != null && !d.DeviceDomainId.Contains(@"\")).ToList())
|
||||
{
|
||||
device.DeviceDomainId = string.Format("{0}\\{1}", netBiosName, device.DeviceDomainId);
|
||||
device.DeviceDomainId = $@"{netBiosName}\{device.DeviceDomainId}";
|
||||
}
|
||||
Database.SaveChanges();
|
||||
|
||||
@@ -462,7 +458,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
|
||||
idExisting.Value = user.UserId;
|
||||
|
||||
SqlParameter idNew = new SqlParameter("@IdNew", System.Data.SqlDbType.NVarChar, 50);
|
||||
idNew.Value = string.Format("{0}\\{1}", netBiosName, user.UserId);
|
||||
idNew.Value = $@"{netBiosName}\{user.UserId}";
|
||||
|
||||
Database.Database.ExecuteSqlCommand(MigratePreDomainUsers_Sql, idExisting, idNew);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace Disco.Data.Repository
|
||||
{
|
||||
@@ -52,18 +48,18 @@ namespace Disco.Data.Repository
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
throw new SecurityException(string.Format("Unable to write to the Registry Location: HKML\\{0}[DatabaseConnectionString]", DiscoRegistryKey), ex);
|
||||
throw new SecurityException($"Unable to write to the Registry Location: HKML\\{DiscoRegistryKey}[DatabaseConnectionString]", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DiscoDatabaseConnectionFactory(IDbConnectionFactory Default)
|
||||
{
|
||||
this.DefaultConnectionFactory = Default;
|
||||
this.SqlCeConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
|
||||
DefaultConnectionFactory = Default;
|
||||
SqlCeConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
|
||||
}
|
||||
|
||||
public System.Data.Common.DbConnection CreateConnection(string nameOrConnectionString)
|
||||
public DbConnection CreateConnection(string nameOrConnectionString)
|
||||
{
|
||||
if (nameOrConnectionString == "Disco.Data.Repository.DiscoDataContext")
|
||||
{
|
||||
@@ -71,7 +67,7 @@ namespace Disco.Data.Repository
|
||||
var connectionString = DiscoDataContextConnectionString;
|
||||
if (connectionString == null)
|
||||
{
|
||||
throw new InvalidOperationException("The Disco DataContext Connection String has not been configured");
|
||||
throw new InvalidOperationException("The Disco ICT DataContext Connection String has not been configured");
|
||||
}
|
||||
|
||||
// Build DiscoDataContext - Use Default Connection Factory (SQLClient)
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Data.Objects;
|
||||
using Disco.Models.Repository;
|
||||
using System.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
|
||||
namespace Disco.Data.Repository.Monitor
|
||||
{
|
||||
@@ -52,9 +49,8 @@ namespace Disco.Data.Repository.Monitor
|
||||
|
||||
private static Type EntityTypeFromProxy(Type EntityProxyType)
|
||||
{
|
||||
Type EntityType;
|
||||
|
||||
if (entityProxyTypeCache.TryGetValue(EntityProxyType, out EntityType))
|
||||
if (entityProxyTypeCache.TryGetValue(EntityProxyType, out var EntityType))
|
||||
return EntityType;
|
||||
|
||||
EntityType = EntityProxyType;
|
||||
@@ -113,7 +109,7 @@ namespace Disco.Data.Repository.Monitor
|
||||
eventType = RepositoryMonitorEventType.Unchanged;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(string.Format("Database Entry State not supported: {0}", entryState.State.ToString()));
|
||||
throw new NotSupportedException($"Database Entry State not supported: {entryState.State.ToString()}");
|
||||
}
|
||||
|
||||
entityType = EntityTypeFromProxy(entryState.Entity.GetType());
|
||||
|
||||
@@ -3,9 +3,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Data.Objects;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Data.Repository.Monitor
|
||||
{
|
||||
@@ -55,7 +52,8 @@ namespace Disco.Data.Repository.Monitor
|
||||
return (T)dbEntityState.CurrentValues[PropertyName];
|
||||
}
|
||||
|
||||
public void ExecuteAfterCommit(Action<RepositoryMonitorEvent> action){
|
||||
public void ExecuteAfterCommit(Action<RepositoryMonitorEvent> action)
|
||||
{
|
||||
if (afterCommit)
|
||||
{
|
||||
// Execute Immediately
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Data.Repository.Monitor
|
||||
namespace Disco.Data.Repository.Monitor
|
||||
{
|
||||
public enum RepositoryMonitorEventType
|
||||
{
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Disco.Models.BI.Config
|
||||
{
|
||||
public class OrganisationAddress
|
||||
{
|
||||
|
||||
public int? Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
@@ -23,54 +20,11 @@ namespace Disco.Models.BI.Config
|
||||
[Required]
|
||||
public string ShortName { get; set; }
|
||||
|
||||
// Added 2012-12-11 G#
|
||||
// http://discoict.com.au/forum/support/2012/12/address-details.aspx
|
||||
public string PhoneNumber { get; set; }
|
||||
public string FaxNumber { get; set; }
|
||||
// End Added 2012-12-11 G#
|
||||
|
||||
public string ToConfigurationEntry()
|
||||
{
|
||||
StringBuilder entryBuilder = new StringBuilder();
|
||||
|
||||
entryBuilder.AppendLine(Name.Trim());
|
||||
entryBuilder.AppendLine(Address.Trim());
|
||||
entryBuilder.AppendLine(Suburb.Trim());
|
||||
entryBuilder.AppendLine(Postcode.Trim());
|
||||
entryBuilder.AppendLine(State.Trim());
|
||||
entryBuilder.AppendLine(Country.Trim());
|
||||
|
||||
if (!string.IsNullOrEmpty(ShortName))
|
||||
{
|
||||
entryBuilder.AppendLine(ShortName.Trim());
|
||||
}
|
||||
|
||||
return entryBuilder.ToString();
|
||||
}
|
||||
|
||||
public static OrganisationAddress FromConfigurationEntry(int Id, string Entry)
|
||||
{
|
||||
string[] entryLines = Entry.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
if (entryLines.Length >= 6)
|
||||
{
|
||||
return new OrganisationAddress()
|
||||
{
|
||||
Id = Id,
|
||||
Name = entryLines[0].Trim(),
|
||||
Address = entryLines[1].Trim(),
|
||||
Suburb = entryLines[2].Trim(),
|
||||
Postcode = entryLines[3].Trim(),
|
||||
State = entryLines[4].Trim(),
|
||||
Country = entryLines[5].Trim(),
|
||||
ShortName = (entryLines.Length > 6 ? entryLines[6].Trim() : string.Empty)
|
||||
};
|
||||
}
|
||||
throw new ArgumentException("Invalid Configuration Address Entry", "entry");
|
||||
}
|
||||
public string EmailAddress { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} ({1})", this.Name, this.ShortName);
|
||||
}
|
||||
=> $"{Name} ({ShortName})";
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user