Feature #67: Advanced document template events

OnGenerated and OnImportAttachment allow advanced users to enter
expressions which will be evaluated whenever these document
template/importing events are triggered. This enables greater
automation.
This commit is contained in:
Gary Sharp
2014-07-26 20:02:59 +10:00
parent c528a2be26
commit 1cc7e94646
32 changed files with 2179 additions and 1474 deletions
@@ -0,0 +1,478 @@
using Disco.Models.Repository;
using Disco.Services.Logging;
using Disco.Services.Logging.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Disco.BI.DocumentTemplateBI
{
public class DocumentsLog : LogBase
{
public enum EventTypeIds
{
ImportStarting = 10,
ImportProgress,
ImportFinished,
ImportWarning = 15,
ImportError,
ImportAttachmentExpressionEvaluated = 50,
ImportPageStarting = 100,
ImportPageImageUpdate = 104,
ImportPageProgress,
ImportPageDetected = 110,
ImportPageUndetected = 115,
ImportPageError = 120,
ImportPageUndetectedStored = 150,
DocumentGenerated = 500,
DocumentGeneratedWithExpression
}
private const int _ModuleId = 40;
public static DocumentsLog Current
{
get
{
return (DocumentsLog)LogContext.LogModules[_ModuleId];
}
}
public override string ModuleDescription
{
get
{
return "Documents";
}
}
public override int ModuleId
{
get
{
return _ModuleId;
}
}
public override string ModuleName
{
get
{
return "Documents";
}
}
private static void Log(DocumentsLog.EventTypeIds EventTypeId, params object[] Args)
{
DocumentsLog.Current.Log((int)EventTypeId, Args);
}
public static void LogImportStarting(string SessionId, string DocumentName)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportStarting, new object[]
{
SessionId,
DocumentName
});
}
public static void LogImportProgress(string SessionId, int? Progress, string Status)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportProgress, new object[]
{
SessionId,
Progress,
Status
});
}
public static void LogImportFinished(string SessionId)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportFinished, new object[]
{
SessionId
});
}
public static void LogImportWarning(string SessionId, string Message)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportWarning, new object[]
{
SessionId,
Message
});
}
public static void LogImportError(string SessionId, string Message)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportError, new object[]
{
SessionId,
Message
});
}
public static void LogImportAttachmentExpressionEvaluated(DocumentTemplate template, Device device, DeviceAttachment attachment, string Result)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportAttachmentExpressionEvaluated, new object[]
{
template.Id,
device.SerialNumber,
attachment.Id,
Result
});
}
public static void LogImportAttachmentExpressionEvaluated(DocumentTemplate template, Job job, JobAttachment attachment, string Result)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportAttachmentExpressionEvaluated, new object[]
{
template.Id,
job.Id,
attachment.Id,
Result
});
}
public static void LogImportAttachmentExpressionEvaluated(DocumentTemplate template, User user, UserAttachment attachment, string Result)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportAttachmentExpressionEvaluated, new object[]
{
template.Id,
user.UserId,
attachment.Id,
Result
});
}
public static void LogImportAttachmentExpressionEvaluated(DocumentTemplate Template, object Data, object Attachment, string Result)
{
if (Data is Job)
LogImportAttachmentExpressionEvaluated(Template, (Job)Data, (JobAttachment)Attachment, Result);
else if (Data is User)
LogImportAttachmentExpressionEvaluated(Template, (User)Data, (UserAttachment)Attachment, Result);
else if (Data is Device)
LogImportAttachmentExpressionEvaluated(Template, (Device)Data, (DeviceAttachment)Attachment, Result);
else
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportAttachmentExpressionEvaluated, new object[]
{
Template.Id,
Data.ToString(),
Attachment.ToString(),
Result
});
}
public static void LogImportPageStarting(string SessionId, int PageNumber)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageStarting, new object[]
{
SessionId,
PageNumber
});
}
public static void LogImportPageImageUpdate(string SessionId, int PageNumber)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageImageUpdate, new object[]
{
SessionId,
PageNumber
});
}
public static void LogImportPageProgress(string SessionId, int PageNumber, int? Progress, string Status)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageProgress, new object[]
{
SessionId,
PageNumber,
Progress,
Status
});
}
public static void LogImportPageDetected(string SessionId, int PageNumber, string DocumentTypeId, string DocumentTypeName, string TargetType, string AssignedId, string AssignedName)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageDetected, new object[]
{
SessionId,
PageNumber,
DocumentTypeId,
DocumentTypeName,
TargetType,
AssignedId,
AssignedName
});
}
public static void LogImportPageUndetected(string SessionId, int PageNumber)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageUndetected, new object[]
{
SessionId,
PageNumber
});
}
public static void LogImportPageError(string SessionId, int PageNumber, string Message)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageError, new object[]
{
SessionId,
PageNumber,
Message
});
}
public static void LogImportPageUndetectedStored(string SessionId, int PageNumber)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageUndetectedStored, new object[]
{
SessionId,
PageNumber
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, Device Device, User Author, string ExpressionResult)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGeneratedWithExpression, new object[]
{
Template.Id,
Device.SerialNumber,
Author.UserId,
ExpressionResult
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, Job Job, User Author, string ExpressionResult)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGeneratedWithExpression, new object[]
{
Template.Id,
Job.Id,
Author.UserId,
ExpressionResult
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, User User, User Author, string ExpressionResult)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGeneratedWithExpression, new object[]
{
Template.Id,
User.UserId,
Author.UserId,
ExpressionResult
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, object Data, User Author, string ExpressionResult)
{
if (Data is Job)
LogDocumentGenerated(Template, (Job)Data, Author, ExpressionResult);
else if (Data is User)
LogDocumentGenerated(Template, (User)Data, Author, ExpressionResult);
else if (Data is Device)
LogDocumentGenerated(Template, (Device)Data, Author, ExpressionResult);
else
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGeneratedWithExpression, new object[]
{
Template.Id,
"UNKNOWN",
Author.UserId,
ExpressionResult
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, Device Device, User Author)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGenerated, new object[]
{
Template.Id,
Device.SerialNumber,
Author.UserId
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, Job Job, User Author)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGenerated, new object[]
{
Template.Id,
Job.Id,
Author.UserId
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, User User, User Author)
{
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGenerated, new object[]
{
Template.Id,
User.UserId,
Author.UserId
});
}
public static void LogDocumentGenerated(DocumentTemplate Template, object Data, User Author)
{
if (Data is Job)
LogDocumentGenerated(Template, (Job)Data, Author);
else if (Data is User)
LogDocumentGenerated(Template, (User)Data, Author);
else if (Data is Device)
LogDocumentGenerated(Template, (Device)Data, Author);
else
DocumentsLog.Log(DocumentsLog.EventTypeIds.DocumentGenerated, new object[]
{
Template.Id,
"UNKNOWN",
Author.UserId
});
}
protected override System.Collections.Generic.List<LogEventType> LoadEventTypes()
{
return new System.Collections.Generic.List<LogEventType>
{
new LogEventType
{
Id = (int)EventTypeIds.ImportStarting,
ModuleId = _ModuleId,
Name = "Import Starting",
Format = "Starting import of document: {1} (SessionId: {0})",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportProgress,
ModuleId = _ModuleId,
Name = "Import Progress",
Format = "Processing: {1}% Complete; Status: {2}",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = false,
UseDisplay = false
},
new LogEventType
{
Id = (int)EventTypeIds.ImportFinished,
ModuleId = _ModuleId,
Name = "Import Finished",
Format = "Import of document complete (SessionId: {0})",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportWarning,
ModuleId = _ModuleId,
Name = "Import Warning",
Format = "Import Warning: {1} (SessionId: {0})",
Severity = (int)LogEventType.Severities.Warning,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportError,
ModuleId = _ModuleId,
Name = "Import Error",
Format = "Import Error: {1} (SessionId: {0})",
Severity = (int)LogEventType.Severities.Error,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportAttachmentExpressionEvaluated,
ModuleId = _ModuleId,
Name = "Import Attachment Expression Evaluated",
Format = "The import attachment expression for '{0}' was evaluated for '{1}' (attachment id: {2}) with the result: {3}",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportPageStarting,
ModuleId = _ModuleId,
Name = "Import Page Starting",
Format = "Starting import of page: {1} (SessionId: {0})",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportPageImageUpdate,
ModuleId = _ModuleId,
Name = "Import Page Image Update",
Format = null,
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = false,
UseDisplay = false
},
new LogEventType
{
Id = (int)EventTypeIds.ImportPageProgress,
ModuleId = _ModuleId,
Name = "Import Page Progress",
Format = "Processing: Page {1}; {2}% Complete; Status: {3}",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = false,
UseDisplay = false
},
new LogEventType
{
Id = (int)EventTypeIds.ImportPageDetected,
ModuleId = _ModuleId,
Name = "Import Page Assigned",
Format = "Page {1} of type '{3}' assigned to {4}: '{6}'",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportPageUndetected,
ModuleId = _ModuleId,
Name = "Import Page Undetected",
Format = "Page {1} not detected",
Severity = (int)LogEventType.Severities.Warning,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportPageError,
ModuleId = _ModuleId,
Name = "Import Page Error",
Format = "Page {1}, Import Error: {2}",
Severity = (int)LogEventType.Severities.Error,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.ImportPageUndetectedStored,
ModuleId = _ModuleId,
Name = "Import Page Undetected Stored",
Format = null,
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = false,
UseDisplay = false
},
new LogEventType
{
Id = (int)EventTypeIds.DocumentGenerated,
ModuleId = _ModuleId,
Name = "Document Generated",
Format = "A '{0}' document was generated for '{1}' by '{2}'",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = (int)EventTypeIds.DocumentGeneratedWithExpression,
ModuleId = _ModuleId,
Name = "Document Generated with Expression",
Format = "A '{0}' document was generated for '{1}' by '{2}'. The expression returned: {3}",
Severity = (int)LogEventType.Severities.Information,
UseLive = true,
UsePersist = true,
UseDisplay = true
}
};
}
}
}
@@ -28,12 +28,12 @@ namespace Disco.BI.DocumentTemplateBI.Importer
if (!string.IsNullOrEmpty(friendlyFilename)) if (!string.IsNullOrEmpty(friendlyFilename))
friendlyFilename = System.IO.Path.GetFileName(friendlyFilename); friendlyFilename = System.IO.Path.GetFileName(friendlyFilename);
DocumentImporterLog.LogImportStarting(sessionId, friendlyFilename); DocumentsLog.LogImportStarting(sessionId, friendlyFilename);
if (!File.Exists(filename)) if (!File.Exists(filename))
{ {
DocumentImporterLog.LogImportWarning(sessionId, string.Format("File not found: {0}", filename)); DocumentsLog.LogImportWarning(sessionId, string.Format("File not found: {0}", filename));
DocumentImporterLog.LogImportFinished(sessionId); DocumentsLog.LogImportFinished(sessionId);
context.Scheduler.DeleteJob(context.JobDetail.Key); context.Scheduler.DeleteJob(context.JobDetail.Key);
return; return;
} }
@@ -79,7 +79,7 @@ namespace Disco.BI.DocumentTemplateBI.Importer
else else
{ {
// To Many Errors // To Many Errors
DocumentImporterLog.LogImportError(sessionId, string.Format("To many errors occurred trying to import '{1}' (SessionId: {0})", sessionId, friendlyFilename)); DocumentsLog.LogImportError(sessionId, string.Format("To many errors occurred trying to import '{1}' (SessionId: {0})", sessionId, friendlyFilename));
// Move to Errors Folder // Move to Errors Folder
if (File.Exists(filename)) if (File.Exists(filename))
{ {
@@ -101,14 +101,14 @@ namespace Disco.BI.DocumentTemplateBI.Importer
} }
} }
} }
DocumentImporterLog.LogImportFinished(sessionId); DocumentsLog.LogImportFinished(sessionId);
// All Done // All Done
context.Scheduler.DeleteJob(context.JobDetail.Key); context.Scheduler.DeleteJob(context.JobDetail.Key);
} }
catch (Exception ex) catch (Exception ex)
{ {
DocumentImporterLog.LogImportWarning(sessionId, string.Format("{0}; Will try again in 10 Seconds", ex.Message)); DocumentsLog.LogImportWarning(sessionId, string.Format("{0}; Will try again in 10 Seconds", ex.Message));
// Reschedule Job for 10 seconds // Reschedule Job for 10 seconds
SimpleTriggerImpl trig = new SimpleTriggerImpl(Guid.NewGuid().ToString(), new DateTimeOffset(DateTime.Now.AddSeconds(10))); SimpleTriggerImpl trig = new SimpleTriggerImpl(Guid.NewGuid().ToString(), new DateTimeOffset(DateTime.Now.AddSeconds(10)));
context.Scheduler.RescheduleJob(context.Trigger.Key, trig); context.Scheduler.RescheduleJob(context.Trigger.Key, trig);
@@ -1,304 +0,0 @@
using Disco.Services.Logging;
using Disco.Services.Logging.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Disco.BI.DocumentTemplateBI.Importer
{
public class DocumentImporterLog : LogBase
{
public enum EventTypeIds
{
ImportStarting = 10,
ImportProgress,
ImportFinished,
ImportWarning = 15,
ImportError,
ImportPageStarting = 100,
ImportPageImageUpdate = 104,
ImportPageProgress,
ImportPageDetected = 110,
ImportPageUndetected = 115,
ImportPageError = 120,
ImportPageUndetectedStored = 150
}
private const int _ModuleId = 40;
public static DocumentImporterLog Current
{
get
{
return (DocumentImporterLog)LogContext.LogModules[_ModuleId];
}
}
public override string ModuleDescription
{
get
{
return "Document Importer";
}
}
public override int ModuleId
{
get
{
return _ModuleId;
}
}
public override string ModuleName
{
get
{
return "DocumentImporter";
}
}
private static void Log(DocumentImporterLog.EventTypeIds EventTypeId, params object[] Args)
{
DocumentImporterLog.Current.Log((int)EventTypeId, Args);
}
public static void LogImportStarting(string SessionId, string DocumentName)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportStarting, new object[]
{
SessionId,
DocumentName
});
}
public static void LogImportProgress(string SessionId, int? Progress, string Status)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportProgress, new object[]
{
SessionId,
Progress,
Status
});
}
public static void LogImportFinished(string SessionId)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportFinished, new object[]
{
SessionId
});
}
public static void LogImportWarning(string SessionId, string Message)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportWarning, new object[]
{
SessionId,
Message
});
}
public static void LogImportError(string SessionId, string Message)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportError, new object[]
{
SessionId,
Message
});
}
public static void LogImportPageStarting(string SessionId, int PageNumber)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportPageStarting, new object[]
{
SessionId,
PageNumber
});
}
public static void LogImportPageImageUpdate(string SessionId, int PageNumber)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportPageImageUpdate, new object[]
{
SessionId,
PageNumber
});
}
public static void LogImportPageProgress(string SessionId, int PageNumber, int? Progress, string Status)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportPageProgress, new object[]
{
SessionId,
PageNumber,
Progress,
Status
});
}
public static void LogImportPageDetected(string SessionId, int PageNumber, string DocumentTypeId, string DocumentTypeName, string TargetType, string AssignedId, string AssignedName)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportPageDetected, new object[]
{
SessionId,
PageNumber,
DocumentTypeId,
DocumentTypeName,
TargetType,
AssignedId,
AssignedName
});
}
public static void LogImportPageUndetected(string SessionId, int PageNumber)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportPageUndetected, new object[]
{
SessionId,
PageNumber
});
}
public static void LogImportPageError(string SessionId, int PageNumber, string Message)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportPageError, new object[]
{
SessionId,
PageNumber,
Message
});
}
public static void LogImportPageUndetectedStored(string SessionId, int PageNumber)
{
DocumentImporterLog.Log(DocumentImporterLog.EventTypeIds.ImportPageUndetectedStored, new object[]
{
SessionId,
PageNumber
});
}
protected override System.Collections.Generic.List<LogEventType> LoadEventTypes()
{
return new System.Collections.Generic.List<LogEventType>
{
new LogEventType
{
Id = 10,
ModuleId = 40,
Name = "Import Starting",
Format = "Starting import of document: {1} (SessionId: {0})",
Severity = 0,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 11,
ModuleId = 40,
Name = "Import Progress",
Format = "Processing: {1}% Complete; Status: {2}",
Severity = 0,
UseLive = true,
UsePersist = false,
UseDisplay = false
},
new LogEventType
{
Id = 12,
ModuleId = 40,
Name = "Import Finished",
Format = "Import of document complete (SessionId: {0})",
Severity = 0,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 15,
ModuleId = 40,
Name = "Import Warning",
Format = "Import Warning: {1} (SessionId: {0})",
Severity = 1,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 16,
ModuleId = 40,
Name = "Import Error",
Format = "Import Error: {1} (SessionId: {0})",
Severity = 2,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 100,
ModuleId = 40,
Name = "Import Page Starting",
Format = "Starting import of page: {1} (SessionId: {0})",
Severity = 0,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 104,
ModuleId = 40,
Name = "Import Page Image Update",
Format = null,
Severity = 0,
UseLive = true,
UsePersist = false,
UseDisplay = false
},
new LogEventType
{
Id = 105,
ModuleId = 40,
Name = "Import Page Progress",
Format = "Processing: Page {1}; {2}% Complete; Status: {3}",
Severity = 0,
UseLive = true,
UsePersist = false,
UseDisplay = false
},
new LogEventType
{
Id = 110,
ModuleId = 40,
Name = "Import Page Assigned",
Format = "Page {1} of type '{3}' assigned to {4}: '{6}'",
Severity = 0,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 115,
ModuleId = 40,
Name = "Import Page Undetected",
Format = "Page {1} not detected",
Severity = 1,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 120,
ModuleId = 40,
Name = "Import Page Error",
Format = "Page {1}, Import Error: {2}",
Severity = 2,
UseLive = true,
UsePersist = true,
UseDisplay = true
},
new LogEventType
{
Id = 150,
ModuleId = 40,
Name = "Import Page Undetected Stored",
Format = null,
Severity = 0,
UseLive = true,
UsePersist = false,
UseDisplay = false
}
};
}
}
}
+21 -7
View File
@@ -7,6 +7,7 @@ using Disco.Data.Repository;
using System.IO; using System.IO;
using Disco.BI.DocumentTemplateBI; using Disco.BI.DocumentTemplateBI;
using Disco.Services.Users; using Disco.Services.Users;
using Disco.Services.Logging;
namespace Disco.BI.Extensions namespace Disco.BI.Extensions
{ {
@@ -15,11 +16,11 @@ namespace Disco.BI.Extensions
public static bool ImportPdfAttachment(this DocumentUniqueIdentifier UniqueIdentifier, DiscoDataContext Database, System.IO.Stream PdfContent, byte[] PdfThumbnail) public static bool ImportPdfAttachment(this DocumentUniqueIdentifier UniqueIdentifier, DiscoDataContext Database, System.IO.Stream PdfContent, byte[] PdfThumbnail)
{ {
UniqueIdentifier.LoadComponents(Database); UniqueIdentifier.LoadComponents(Database);
DocumentTemplate documentTemplate = UniqueIdentifier.DocumentTemplate; DocumentTemplate documentTemplate = UniqueIdentifier.DocumentTemplate;
string filename; string filename;
string comments; string comments;
object attachment;
if (documentTemplate == null) if (documentTemplate == null)
{ {
@@ -42,20 +43,33 @@ namespace Disco.BI.Extensions
{ {
case DocumentTemplate.DocumentTemplateScopes.Device: case DocumentTemplate.DocumentTemplateScopes.Device:
Device d = (Device)UniqueIdentifier.Data; Device d = (Device)UniqueIdentifier.Data;
d.CreateAttachment(Database, creatorUser, filename, DocumentTemplate.PdfMimeType, comments, PdfContent, documentTemplate, PdfThumbnail); attachment = d.CreateAttachment(Database, creatorUser, filename, DocumentTemplate.PdfMimeType, comments, PdfContent, documentTemplate, PdfThumbnail);
return true; break;
case DocumentTemplate.DocumentTemplateScopes.Job: case DocumentTemplate.DocumentTemplateScopes.Job:
Job j = (Job)UniqueIdentifier.Data; Job j = (Job)UniqueIdentifier.Data;
j.CreateAttachment(Database, creatorUser, filename, DocumentTemplate.PdfMimeType, comments, PdfContent, documentTemplate, PdfThumbnail); attachment = j.CreateAttachment(Database, creatorUser, filename, DocumentTemplate.PdfMimeType, comments, PdfContent, documentTemplate, PdfThumbnail);
return true; break;
case DocumentTemplate.DocumentTemplateScopes.User: case DocumentTemplate.DocumentTemplateScopes.User:
User u = (User)UniqueIdentifier.Data; User u = (User)UniqueIdentifier.Data;
u.CreateAttachment(Database, creatorUser, filename, DocumentTemplate.PdfMimeType, comments, PdfContent, documentTemplate, PdfThumbnail); attachment = u.CreateAttachment(Database, creatorUser, filename, DocumentTemplate.PdfMimeType, comments, PdfContent, documentTemplate, PdfThumbnail);
return true; break;
default: default:
return false; return false;
} }
if (documentTemplate != null && !string.IsNullOrWhiteSpace(documentTemplate.OnImportAttachmentExpression))
{
try
{
var expressionResult = documentTemplate.EvaluateOnAttachmentImportExpression(attachment, Database, creatorUser, UniqueIdentifier.TimeStamp);
DocumentsLog.LogImportAttachmentExpressionEvaluated(documentTemplate, UniqueIdentifier.Data, attachment, expressionResult);
}
catch (Exception ex)
{
SystemLog.LogException("Document Importer - OnImportAttachmentExpression", ex);
}
}
return true;
} }
public static string RepositoryFilename(this DeviceAttachment da, DiscoDataContext Database) public static string RepositoryFilename(this DeviceAttachment da, DiscoDataContext Database)
@@ -75,16 +75,29 @@ namespace Disco.BI.Extensions
} }
public static System.IO.Stream GeneratePdf(this DocumentTemplate dt, DiscoDataContext Database, object Data, User CreatorUser, System.DateTime TimeStamp, DocumentState State, bool FlattenFields = false) public static System.IO.Stream GeneratePdf(this DocumentTemplate dt, DiscoDataContext Database, object Data, User CreatorUser, System.DateTime TimeStamp, DocumentState State, bool FlattenFields = false)
{ {
return Interop.Pdf.PdfGenerator.GenerateFromTemplate(dt, Database, Data, CreatorUser, TimeStamp, State, FlattenFields); bool generateExpression = !string.IsNullOrEmpty(dt.OnGenerateExpression);
string generateExpressionResult = null;
if (generateExpression)
generateExpressionResult = dt.EvaluateOnGenerateExpression(Data, Database, CreatorUser, TimeStamp, State);
var pdfStream = Interop.Pdf.PdfGenerator.GenerateFromTemplate(dt, Database, Data, CreatorUser, TimeStamp, State, FlattenFields);
if (generateExpression)
DocumentsLog.LogDocumentGenerated(dt, Data, CreatorUser, generateExpressionResult);
else
DocumentsLog.LogDocumentGenerated(dt, Data, CreatorUser);
return pdfStream;
} }
public static Expression FilterExpressionFromCache(this DocumentTemplate dt) public static Expression FilterExpressionFromCache(this DocumentTemplate dt)
{ {
return ExpressionCache.GetValue("DocumentTemplateFilterExpression", dt.Id, () => { return Expression.TokenizeSingleDynamic(null, dt.FilterExpression, 0); }); return ExpressionCache.GetValue("DocumentTemplate_FilterExpression", dt.Id, () => { return Expression.TokenizeSingleDynamic(null, dt.FilterExpression, 0); });
} }
public static void FilterExpressionInvalidateCache(this DocumentTemplate dt) public static void FilterExpressionInvalidateCache(this DocumentTemplate dt)
{ {
ExpressionCache.InvalidateKey("DocumentTemplateFilterExpression", dt.Id); ExpressionCache.InvalidateKey("DocumentTemplate_FilterExpression", dt.Id);
} }
public static bool FilterExpressionMatches(this DocumentTemplate dt, object Data, DiscoDataContext Database, User User, System.DateTime TimeStamp, DocumentState State) public static bool FilterExpressionMatches(this DocumentTemplate dt, object Data, DiscoDataContext Database, User User, System.DateTime TimeStamp, DocumentState State)
{ {
@@ -112,6 +125,64 @@ namespace Disco.BI.Extensions
} }
return true; return true;
} }
public static Expression OnImportAttachmentExpressionFromCache(this DocumentTemplate dt)
{
return ExpressionCache.GetValue("DocumentTemplate_OnImportExpression", dt.Id, () => { return Expression.TokenizeSingleDynamic(null, dt.OnImportAttachmentExpression, 0); });
}
public static void OnImportAttachmentExpressionInvalidateCache(this DocumentTemplate dt)
{
ExpressionCache.InvalidateKey("DocumentTemplate_OnImportExpression", dt.Id);
}
public static string EvaluateOnAttachmentImportExpression(this DocumentTemplate dt, object Data, DiscoDataContext Database, User User, System.DateTime TimeStamp)
{
if (!string.IsNullOrEmpty(dt.OnImportAttachmentExpression))
{
Expression compiledExpression = dt.OnImportAttachmentExpressionFromCache();
System.Collections.IDictionary evaluatorVariables = Expression.StandardVariables(dt, Database, User, TimeStamp, null);
try
{
object result = compiledExpression.EvaluateFirst<object>(Data, evaluatorVariables);
if (result == null)
return null;
else
return result.ToString();
}
catch
{
throw;
}
}
return null;
}
public static Expression OnGenerateExpressionFromCache(this DocumentTemplate dt)
{
return ExpressionCache.GetValue("DocumentTemplate_OnGenerateExpression", dt.Id, () => { return Expression.TokenizeSingleDynamic(null, dt.OnGenerateExpression, 0); });
}
public static void OnGenerateExpressionInvalidateCache(this DocumentTemplate dt)
{
ExpressionCache.InvalidateKey("DocumentTemplate_OnGenerateExpression", dt.Id);
}
public static string EvaluateOnGenerateExpression(this DocumentTemplate dt, object Data, DiscoDataContext Database, User User, System.DateTime TimeStamp, DocumentState State)
{
if (!string.IsNullOrEmpty(dt.OnGenerateExpression))
{
Expression compiledExpression = dt.OnGenerateExpressionFromCache();
System.Collections.IDictionary evaluatorVariables = Expression.StandardVariables(dt, Database, User, TimeStamp, State);
try
{
object result = compiledExpression.EvaluateFirst<object>(Data, evaluatorVariables);
return result.ToString();
}
catch
{
throw;
}
}
return null;
}
public static string GetDataId(this DocumentTemplate dt, object Data) public static string GetDataId(this DocumentTemplate dt, object Data)
{ {
if (Data is string) if (Data is string)
+21 -15
View File
@@ -307,7 +307,7 @@ namespace Disco.BI.Interop.Pdf
{ {
DetectPageResult result = new DetectPageResult() { PageNumber = PageNumber }; DetectPageResult result = new DetectPageResult() { PageNumber = PageNumber };
DocumentImporterLog.LogImportPageProgress(SessionId, PageNumber, 10, "Loading Page Images"); DocumentsLog.LogImportPageProgress(SessionId, PageNumber, 10, "Loading Page Images");
using (DisposableImageCollection pageImages = pdfReader.PdfPageImages(PageNumber)) using (DisposableImageCollection pageImages = pdfReader.PdfPageImages(PageNumber))
{ {
@@ -317,13 +317,13 @@ namespace Disco.BI.Interop.Pdf
var pageThumbnailFilename = Path.Combine(DataStoreSessionCacheLocation, string.Format("{0}-{1}", SessionId, PageNumber)); var pageThumbnailFilename = Path.Combine(DataStoreSessionCacheLocation, string.Format("{0}-{1}", SessionId, PageNumber));
result.ThumbnailImage.Montage.SavePng(pageThumbnailFilename); result.ThumbnailImage.Montage.SavePng(pageThumbnailFilename);
DocumentImporterLog.LogImportPageImageUpdate(SessionId, PageNumber); DocumentsLog.LogImportPageImageUpdate(SessionId, PageNumber);
double pageProgressInterval = 90 / pageImages.Count; double pageProgressInterval = 90 / pageImages.Count;
foreach (var pageImageOriginal in pageImages) foreach (var pageImageOriginal in pageImages)
{ {
DocumentImporterLog.LogImportPageProgress(SessionId, PageNumber, (int)(10 + (pageProgressInterval * pageImages.IndexOf(pageImageOriginal))), String.Format("Processing Page Image {0} of {1}", pageImages.IndexOf(pageImageOriginal) + 1, pageImages.Count)); DocumentsLog.LogImportPageProgress(SessionId, PageNumber, (int)(10 + (pageProgressInterval * pageImages.IndexOf(pageImageOriginal))), String.Format("Processing Page Image {0} of {1}", pageImages.IndexOf(pageImageOriginal) + 1, pageImages.Count));
using (var zxingResult = DetectImage(Database, pageImageOriginal, SessionId, detectDocumentTemplates, StateHints)) using (var zxingResult = DetectImage(Database, pageImageOriginal, SessionId, detectDocumentTemplates, StateHints))
{ {
@@ -343,7 +343,7 @@ namespace Disco.BI.Interop.Pdf
} }
result.ThumbnailImage.Montage.SavePng(pageThumbnailFilename); result.ThumbnailImage.Montage.SavePng(pageThumbnailFilename);
DocumentImporterLog.LogImportPageImageUpdate(SessionId, PageNumber); DocumentsLog.LogImportPageImageUpdate(SessionId, PageNumber);
result.AttachmentThumbnailImage = new MemoryStream(); result.AttachmentThumbnailImage = new MemoryStream();
using (var attachmentThumbImage = pageImages.BuildImageMontage(48, 48, true)) using (var attachmentThumbImage = pageImages.BuildImageMontage(48, 48, true))
@@ -381,7 +381,7 @@ namespace Disco.BI.Interop.Pdf
{ {
var dataStoreUnassignedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned"); var dataStoreUnassignedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned");
DocumentImporterLog.LogImportProgress(SessionId, 0, "Reading File"); DocumentsLog.LogImportProgress(SessionId, 0, "Reading File");
using (FileStream fs = new FileStream(Filename, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) using (FileStream fs = new FileStream(Filename, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
{ {
@@ -398,8 +398,8 @@ namespace Disco.BI.Interop.Pdf
for (int PageNumber = 1; PageNumber <= pdfReader.NumberOfPages; PageNumber++) for (int PageNumber = 1; PageNumber <= pdfReader.NumberOfPages; PageNumber++)
{ {
DocumentImporterLog.LogImportProgress(SessionId, (int)(PageNumber * progressInterval), string.Format("Processing Page {0} of {1}", PageNumber, pdfReader.NumberOfPages)); DocumentsLog.LogImportProgress(SessionId, (int)(PageNumber * progressInterval), string.Format("Processing Page {0} of {1}", PageNumber, pdfReader.NumberOfPages));
DocumentImporterLog.LogImportPageStarting(SessionId, PageNumber); DocumentsLog.LogImportPageStarting(SessionId, PageNumber);
using (var pageResult = DetectPage(Database, pdfReader, PageNumber, SessionId, dataStoreSessionPagesCacheLocation, detectDocumentTemplates, detectStateHints)) using (var pageResult = DetectPage(Database, pdfReader, PageNumber, SessionId, dataStoreSessionPagesCacheLocation, detectDocumentTemplates, detectStateHints))
{ {
@@ -409,19 +409,25 @@ namespace Disco.BI.Interop.Pdf
pdfPagesAssigned.Add(PageNumber, new Tuple<DocumentUniqueIdentifier, byte[]>(docId, pageResult.AttachmentThumbnailImage.ToArray())); pdfPagesAssigned.Add(PageNumber, new Tuple<DocumentUniqueIdentifier, byte[]>(docId, pageResult.AttachmentThumbnailImage.ToArray()));
docId.LoadComponents(Database); docId.LoadComponents(Database);
DocumentImporterLog.LogImportPageDetected(SessionId, PageNumber, docId.TemplateTypeId, docId.DocumentTemplate.Description, docId.DocumentTemplate.Scope, docId.DataId, docId.DataDescription); DocumentsLog.LogImportPageDetected(SessionId, PageNumber, docId.TemplateTypeId, docId.DocumentTemplate.Description, docId.DocumentTemplate.Scope, docId.DataId, docId.DataDescription);
} }
else else
{ {
// Undetected Page - Write Preview-Images while still in Memory // Undetected Page - Write Preview-Images while still in Memory
DocumentImporterLog.LogImportPageUndetected(SessionId, PageNumber); DocumentsLog.LogImportPageUndetected(SessionId, PageNumber);
// Thumbnail: // Thumbnail:
string unassignedImageThumbnailFilename = Path.Combine(dataStoreUnassignedLocation, string.Format("{0}_{1}_thumbnail.png", SessionId, PageNumber)); string unassignedImageThumbnailFilename = Path.Combine(dataStoreUnassignedLocation, string.Format("{0}_{1}_thumbnail.png", SessionId, PageNumber));
pageResult.ThumbnailImage.Montage.SavePng(unassignedImageThumbnailFilename); if (pageResult.ThumbnailImage != null)
pageResult.ThumbnailImage.Montage.SavePng(unassignedImageThumbnailFilename);
else
Disco.Properties.Resources.MimeType_pdf48.SavePng(unassignedImageThumbnailFilename);
// Large Preview // Large Preview
string unassignedImageFilename = Path.Combine(dataStoreUnassignedLocation, string.Format("{0}_{1}.jpg", SessionId, PageNumber)); string unassignedImageFilename = Path.Combine(dataStoreUnassignedLocation, string.Format("{0}_{1}.jpg", SessionId, PageNumber));
pageResult.UndetectedPageImage.Montage.SaveJpg(90, unassignedImageFilename); if (pageResult.UndetectedPageImage != null)
pageResult.UndetectedPageImage.Montage.SaveJpg(90, unassignedImageFilename);
else
Disco.Properties.Resources.MimeType_pdf48.SaveJpg(90, unassignedImageFilename);
} }
} }
@@ -435,7 +441,7 @@ namespace Disco.BI.Interop.Pdf
foreach (var documentPortion in assignedDocuments) foreach (var documentPortion in assignedDocuments)
{ {
DocumentImporterLog.LogImportProgress(SessionId, (int)(70 + (assignedDocuments.IndexOf(documentPortion) * progressInterval)), string.Format("Importing Documents {0} of {1}", assignedDocuments.IndexOf(documentPortion) + 1, assignedDocuments.Count)); DocumentsLog.LogImportProgress(SessionId, (int)(70 + (assignedDocuments.IndexOf(documentPortion) * progressInterval)), string.Format("Importing Documents {0} of {1}", assignedDocuments.IndexOf(documentPortion) + 1, assignedDocuments.Count));
var documentPortionInfo = documentPortion.First().Value; var documentPortionInfo = documentPortion.First().Value;
var documentPortionIdentifier = documentPortionInfo.Item1; var documentPortionIdentifier = documentPortionInfo.Item1;
@@ -506,7 +512,7 @@ namespace Disco.BI.Interop.Pdf
//dataStoreUnassignedLocation //dataStoreUnassignedLocation
foreach (var PageNumber in pdfPagesUnassigned) foreach (var PageNumber in pdfPagesUnassigned)
{ {
DocumentImporterLog.LogImportProgress(SessionId, (int)(90 + (pdfPagesUnassigned.IndexOf(PageNumber) * progressInterval)), string.Format("Processing Undetected Documents {0} of {1}", pdfPagesUnassigned.IndexOf(PageNumber) + 1, pdfPagesUnassigned.Count)); DocumentsLog.LogImportProgress(SessionId, (int)(90 + (pdfPagesUnassigned.IndexOf(PageNumber) * progressInterval)), string.Format("Processing Undetected Documents {0} of {1}", pdfPagesUnassigned.IndexOf(PageNumber) + 1, pdfPagesUnassigned.Count));
using (MemoryStream msBuilder = new MemoryStream()) using (MemoryStream msBuilder = new MemoryStream())
{ {
@@ -527,14 +533,14 @@ namespace Disco.BI.Interop.Pdf
File.WriteAllBytes(Path.Combine(dataStoreUnassignedLocation, string.Format("{0}_{1}.pdf", SessionId, PageNumber)), msBuilder.ToArray()); File.WriteAllBytes(Path.Combine(dataStoreUnassignedLocation, string.Format("{0}_{1}.pdf", SessionId, PageNumber)), msBuilder.ToArray());
DocumentImporterLog.LogImportPageUndetectedStored(SessionId, PageNumber); DocumentsLog.LogImportPageUndetectedStored(SessionId, PageNumber);
} }
} }
} }
} }
DocumentImporterLog.LogImportProgress(SessionId, 100, "Finished Importing Document"); DocumentsLog.LogImportProgress(SessionId, 100, "Finished Importing Document");
return true; return true;
} }
+2 -1
View File
@@ -152,7 +152,7 @@
<Compile Include="BI\DocumentTemplateBI\Importer\DocumentDropBoxMonitor.cs" /> <Compile Include="BI\DocumentTemplateBI\Importer\DocumentDropBoxMonitor.cs" />
<Compile Include="BI\DocumentTemplateBI\Importer\DocumentImporterJob.cs" /> <Compile Include="BI\DocumentTemplateBI\Importer\DocumentImporterJob.cs" />
<Compile Include="BI\DocumentTemplateBI\Importer\DocumentImporterCleanCacheJob.cs" /> <Compile Include="BI\DocumentTemplateBI\Importer\DocumentImporterCleanCacheJob.cs" />
<Compile Include="BI\DocumentTemplateBI\Importer\DocumentImporterLog.cs" /> <Compile Include="BI\DocumentTemplateBI\DocumentsLog.cs" />
<Compile Include="BI\Expressions\ExpressionCache.cs" /> <Compile Include="BI\Expressions\ExpressionCache.cs" />
<Compile Include="BI\Interop\MimeTypes.cs" /> <Compile Include="BI\Interop\MimeTypes.cs" />
<Compile Include="BI\Interop\Pdf\PdfGenerator.cs" /> <Compile Include="BI\Interop\Pdf\PdfGenerator.cs" />
@@ -189,6 +189,7 @@
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+8 -1
View File
@@ -146,6 +146,10 @@
<Compile Include="Migrations\201407100413342_DBv15.Designer.cs"> <Compile Include="Migrations\201407100413342_DBv15.Designer.cs">
<DependentUpon>201407100413342_DBv15.cs</DependentUpon> <DependentUpon>201407100413342_DBv15.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Migrations\201407260624238_DBv16.cs" />
<Compile Include="Migrations\201407260624238_DBv16.Designer.cs">
<DependentUpon>201407260624238_DBv16.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" /> <Compile Include="Migrations\Configuration.cs" />
<Compile Include="Migrations\DiscoDataMigrator.cs" /> <Compile Include="Migrations\DiscoDataMigrator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
@@ -206,6 +210,9 @@
<EmbeddedResource Include="Migrations\201407100413342_DBv15.resx"> <EmbeddedResource Include="Migrations\201407100413342_DBv15.resx">
<DependentUpon>201407100413342_DBv15.cs</DependentUpon> <DependentUpon>201407100413342_DBv15.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Migrations\201407260624238_DBv16.resx">
<DependentUpon>201407260624238_DBv16.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -219,7 +226,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions> <ProjectExtensions>
<VisualStudio> <VisualStudio>
<UserProperties BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_StartDate="2014/6/1" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" /> <UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_StartDate="2014/6/1" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" />
</VisualStudio> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv16 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv16));
string IMigrationMetadata.Id
{
get { return "201407260624238_DBv16"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,22 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv16 : DbMigration
{
public override void Up()
{
AddColumn("dbo.DocumentTemplates", "OnGenerateExpression", c => c.String());
AddColumn("dbo.DocumentTemplates", "OnImportAttachmentExpression", c => c.String());
AlterColumn("dbo.DocumentTemplates", "FilterExpression", c => c.String());
}
public override void Down()
{
AlterColumn("dbo.DocumentTemplates", "FilterExpression", c => c.String(maxLength: 250));
DropColumn("dbo.DocumentTemplates", "OnImportAttachmentExpression");
DropColumn("dbo.DocumentTemplates", "OnGenerateExpression");
}
}
}
File diff suppressed because one or more lines are too long
@@ -20,14 +20,14 @@ namespace Disco.Models.Repository
[Required, StringLength(10)] [Required, StringLength(10)]
public string ShortName { get; set; } public string ShortName { get; set; }
[StringLength(500)] [StringLength(500), DataType(DataType.MultilineText)]
public string Description { get; set; } public string Description { get; set; }
public int? DefaultOrganisationAddress { get; set; } public int? DefaultOrganisationAddress { get; set; }
// Migration from DeviceProfile Configuration // Migration from DeviceProfile Configuration
// 2012-06-14 G# // 2012-06-14 G#
[Required] [Required, DataType(DataType.MultilineText)]
public string ComputerNameTemplate { get; set; } public string ComputerNameTemplate { get; set; }
[Required] [Required]
@@ -18,8 +18,12 @@ namespace Disco.Models.Repository
public string Description { get; set; } public string Description { get; set; }
[Required, StringLength(6)] [Required, StringLength(6)]
public string Scope { get; set; } public string Scope { get; set; }
[StringLength(250), DataType(DataType.MultilineText)] [DataType(DataType.MultilineText)]
public string FilterExpression { get; set; } public string FilterExpression { get; set; }
[DataType(DataType.MultilineText)]
public string OnGenerateExpression { get; set; }
[DataType(DataType.MultilineText)]
public string OnImportAttachmentExpression { get; set; }
// Feature Request 2012-05-10 by G#: https://disco.uservoice.com/forums/159707-feedback/suggestions/2811092-document-template-option-flatten-form-on-generate // Feature Request 2012-05-10 by G#: https://disco.uservoice.com/forums/159707-feedback/suggestions/2811092-document-template-option-flatten-form-on-generate
public bool FlattenForm { get; set; } public bool FlattenForm { get; set; }
+8 -8
View File
@@ -45,8 +45,8 @@ namespace Disco.Services.Authorization
{ "Config.DeviceProfile.Delete", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DeviceProfile.Delete, (c, v) => c.Config.DeviceProfile.Delete = v, "Delete Device Profiles", "Can delete device profiles", false) }, { "Config.DeviceProfile.Delete", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DeviceProfile.Delete, (c, v) => c.Config.DeviceProfile.Delete = v, "Delete Device Profiles", "Can delete device profiles", false) },
{ "Config.DeviceProfile.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DeviceProfile.Show, (c, v) => c.Config.DeviceProfile.Show = v, "Show Device Profiles", "Can show device profiles", false) }, { "Config.DeviceProfile.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DeviceProfile.Show, (c, v) => c.Config.DeviceProfile.Show = v, "Show Device Profiles", "Can show device profiles", false) },
{ "Config.DocumentTemplate.BulkGenerate", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.BulkGenerate, (c, v) => c.Config.DocumentTemplate.BulkGenerate = v, "Bulk Generate Document Templates", "Can bulk generate document templates", false) }, { "Config.DocumentTemplate.BulkGenerate", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.BulkGenerate, (c, v) => c.Config.DocumentTemplate.BulkGenerate = v, "Bulk Generate Document Templates", "Can bulk generate document templates", false) },
{ "Config.DocumentTemplate.ConfigureFilterExpression", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.ConfigureFilterExpression, (c, v) => c.Config.DocumentTemplate.ConfigureFilterExpression = v, "Configure Advanced Expression", "Can configure filter, generate and import expressions for document templates", false) },
{ "Config.DocumentTemplate.Configure", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.Configure, (c, v) => c.Config.DocumentTemplate.Configure = v, "Configure Document Templates", "Can configure document templates", false) }, { "Config.DocumentTemplate.Configure", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.Configure, (c, v) => c.Config.DocumentTemplate.Configure = v, "Configure Document Templates", "Can configure document templates", false) },
{ "Config.DocumentTemplate.ConfigureFilterExpression", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.ConfigureFilterExpression, (c, v) => c.Config.DocumentTemplate.ConfigureFilterExpression = v, "Configure Filter Expression", "Can configure filter expressions for document templates", false) },
{ "Config.DocumentTemplate.Create", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.Create, (c, v) => c.Config.DocumentTemplate.Create = v, "Create Document Templates", "Can create document templates", false) }, { "Config.DocumentTemplate.Create", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.Create, (c, v) => c.Config.DocumentTemplate.Create = v, "Create Document Templates", "Can create document templates", false) },
{ "Config.DocumentTemplate.Delete", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.Delete, (c, v) => c.Config.DocumentTemplate.Delete = v, "Delete Document Templates", "Can delete document templates", false) }, { "Config.DocumentTemplate.Delete", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.Delete, (c, v) => c.Config.DocumentTemplate.Delete = v, "Delete Document Templates", "Can delete document templates", false) },
{ "Config.DocumentTemplate.UndetectedPages", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.UndetectedPages, (c, v) => c.Config.DocumentTemplate.UndetectedPages = v, "Process Undetected Pages", "Can show and assign imported documents which were not undetected", false) }, { "Config.DocumentTemplate.UndetectedPages", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.DocumentTemplate.UndetectedPages, (c, v) => c.Config.DocumentTemplate.UndetectedPages = v, "Process Undetected Pages", "Can show and assign imported documents which were not undetected", false) },
@@ -253,8 +253,8 @@ namespace Disco.Services.Authorization
}), }),
new ClaimNavigatorItem("Config.DocumentTemplate", "Document Templates", "Permissions related to Document Templates", false, new List<IClaimNavigatorItem>() { new ClaimNavigatorItem("Config.DocumentTemplate", "Document Templates", "Permissions related to Document Templates", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DocumentTemplate.BulkGenerate", false), new ClaimNavigatorItem("Config.DocumentTemplate.BulkGenerate", false),
new ClaimNavigatorItem("Config.DocumentTemplate.Configure", false),
new ClaimNavigatorItem("Config.DocumentTemplate.ConfigureFilterExpression", false), new ClaimNavigatorItem("Config.DocumentTemplate.ConfigureFilterExpression", false),
new ClaimNavigatorItem("Config.DocumentTemplate.Configure", false),
new ClaimNavigatorItem("Config.DocumentTemplate.Create", false), new ClaimNavigatorItem("Config.DocumentTemplate.Create", false),
new ClaimNavigatorItem("Config.DocumentTemplate.Delete", false), new ClaimNavigatorItem("Config.DocumentTemplate.Delete", false),
new ClaimNavigatorItem("Config.DocumentTemplate.UndetectedPages", false), new ClaimNavigatorItem("Config.DocumentTemplate.UndetectedPages", false),
@@ -559,8 +559,8 @@ namespace Disco.Services.Authorization
c.Config.DeviceProfile.Delete = true; c.Config.DeviceProfile.Delete = true;
c.Config.DeviceProfile.Show = true; c.Config.DeviceProfile.Show = true;
c.Config.DocumentTemplate.BulkGenerate = true; c.Config.DocumentTemplate.BulkGenerate = true;
c.Config.DocumentTemplate.Configure = true;
c.Config.DocumentTemplate.ConfigureFilterExpression = true; c.Config.DocumentTemplate.ConfigureFilterExpression = true;
c.Config.DocumentTemplate.Configure = true;
c.Config.DocumentTemplate.Create = true; c.Config.DocumentTemplate.Create = true;
c.Config.DocumentTemplate.Delete = true; c.Config.DocumentTemplate.Delete = true;
c.Config.DocumentTemplate.UndetectedPages = true; c.Config.DocumentTemplate.UndetectedPages = true;
@@ -897,16 +897,16 @@ namespace Disco.Services.Authorization
/// </summary> /// </summary>
public const string BulkGenerate = "Config.DocumentTemplate.BulkGenerate"; public const string BulkGenerate = "Config.DocumentTemplate.BulkGenerate";
/// <summary>Configure Advanced Expression
/// <para>Can configure filter, generate and import expressions for document templates</para>
/// </summary>
public const string ConfigureFilterExpression = "Config.DocumentTemplate.ConfigureFilterExpression";
/// <summary>Configure Document Templates /// <summary>Configure Document Templates
/// <para>Can configure document templates</para> /// <para>Can configure document templates</para>
/// </summary> /// </summary>
public const string Configure = "Config.DocumentTemplate.Configure"; public const string Configure = "Config.DocumentTemplate.Configure";
/// <summary>Configure Filter Expression
/// <para>Can configure filter expressions for document templates</para>
/// </summary>
public const string ConfigureFilterExpression = "Config.DocumentTemplate.ConfigureFilterExpression";
/// <summary>Create Document Templates /// <summary>Create Document Templates
/// <para>Can create document templates</para> /// <para>Can create document templates</para>
/// </summary> /// </summary>
@@ -12,7 +12,7 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DocumentT
[ClaimDetails("Configure Document Templates", "Can configure document templates")] [ClaimDetails("Configure Document Templates", "Can configure document templates")]
public bool Configure { get; set; } public bool Configure { get; set; }
[ClaimDetails("Configure Filter Expression", "Can configure filter expressions for document templates")] [ClaimDetails("Configure Advanced Expression", "Can configure filter, generate and import expressions for document templates")]
public bool ConfigureFilterExpression { get; set; } public bool ConfigureFilterExpression { get; set; }
[ClaimDetails("Upload Document Templates", "Can upload document templates")] [ClaimDetails("Upload Document Templates", "Can upload document templates")]
+3 -1
View File
@@ -54,9 +54,11 @@ namespace Disco.Services.Logging
LogModules = new Dictionary<int, LogBase>(); LogModules = new Dictionary<int, LogBase>();
// Load all LogModules (Only from Disco Assemblies) // Load all LogModules (Only from Disco Assemblies)
var appDomain = AppDomain.CurrentDomain; var appDomain = AppDomain.CurrentDomain;
var servicesAssemblyName = typeof(LogContext).Assembly.GetName().Name;
var logModuleTypes = (from a in appDomain.GetAssemblies() var logModuleTypes = (from a in appDomain.GetAssemblies()
where !a.GlobalAssemblyCache && !a.IsDynamic && a.FullName.StartsWith("Disco.", StringComparison.OrdinalIgnoreCase) where !a.GlobalAssemblyCache && !a.IsDynamic &&
(a.GetName().Name == servicesAssemblyName || a.GetReferencedAssemblies().Any(ra => ra.Name == servicesAssemblyName))
from type in a.GetTypes() from type in a.GetTypes()
where typeof(LogBase).IsAssignableFrom(type) && !type.IsAbstract where typeof(LogBase).IsAssignableFrom(type) && !type.IsAbstract
select type); select type);
+2 -2
View File
@@ -32,12 +32,12 @@ namespace Disco.Services.Tasks
{ {
// Discover DiscoScheduledTask // Discover DiscoScheduledTask
var appDomain = AppDomain.CurrentDomain; var appDomain = AppDomain.CurrentDomain;
var scheduledTasksHostAssemblyName = typeof(ScheduledTask).Assembly.GetName().Name; var servicesAssemblyName = typeof(ScheduledTask).Assembly.GetName().Name;
var scheduledTaskTypes = (from a in appDomain.GetAssemblies() var scheduledTaskTypes = (from a in appDomain.GetAssemblies()
where !a.GlobalAssemblyCache && where !a.GlobalAssemblyCache &&
!a.IsDynamic && !a.IsDynamic &&
(a.GetName().Name == scheduledTasksHostAssemblyName || a.GetReferencedAssemblies().Any(ra => ra.Name == scheduledTasksHostAssemblyName)) (a.GetName().Name == servicesAssemblyName || a.GetReferencedAssemblies().Any(ra => ra.Name == servicesAssemblyName))
from type in a.GetTypes() from type in a.GetTypes()
where typeof(ScheduledTask).IsAssignableFrom(type) && !type.IsAbstract where typeof(ScheduledTask).IsAssignableFrom(type) && !type.IsAbstract
select type); select type);
@@ -21,6 +21,8 @@ namespace Disco.Web.Areas.API.Controllers
const string pDescription = "description"; const string pDescription = "description";
const string pScope = "scope"; const string pScope = "scope";
const string pFilterExpression = "filterexpression"; const string pFilterExpression = "filterexpression";
const string pOnGenerateExpression = "ongenerateexpression";
const string pOnImportAttachmentExpression = "onimportattachmentexpression";
const string pFlattenForm = "flattenform"; const string pFlattenForm = "flattenform";
[DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)] [DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)]
@@ -50,6 +52,12 @@ namespace Disco.Web.Areas.API.Controllers
Authorization.Require(Claims.Config.DocumentTemplate.ConfigureFilterExpression); Authorization.Require(Claims.Config.DocumentTemplate.ConfigureFilterExpression);
UpdateFilterExpression(documentTemplate, value); UpdateFilterExpression(documentTemplate, value);
break; break;
case pOnGenerateExpression:
UpdateOnGenerateExpression(documentTemplate, value);
break;
case pOnImportAttachmentExpression:
UpdateOnImportAttachmentExpression(documentTemplate, value);
break;
case pFlattenForm: case pFlattenForm:
UpdateFlattenForm(documentTemplate, value); UpdateFlattenForm(documentTemplate, value);
break; break;
@@ -141,6 +149,16 @@ namespace Disco.Web.Areas.API.Controllers
{ {
return Update(id, pFilterExpression, FilterExpression, redirect); return Update(id, pFilterExpression, FilterExpression, redirect);
} }
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Configure, Claims.Config.DocumentTemplate.ConfigureFilterExpression)]
public virtual ActionResult UpdateOnGenerateExpression(string id, string OnGenerateExpression = null, bool redirect = false)
{
return Update(id, pOnGenerateExpression, OnGenerateExpression, redirect);
}
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.Configure, Claims.Config.DocumentTemplate.ConfigureFilterExpression)]
public virtual ActionResult UpdateOnImportAttachmentExpression(string id, string OnImportAttachmentExpression = null, bool redirect = false)
{
return Update(id, pOnImportAttachmentExpression, OnImportAttachmentExpression, redirect);
}
[DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)] [DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)]
public virtual ActionResult UpdateFlattenForm(string id, string FlattenForm = null, bool redirect = false) public virtual ActionResult UpdateFlattenForm(string id, string FlattenForm = null, bool redirect = false)
{ {
@@ -303,6 +321,36 @@ namespace Disco.Web.Areas.API.Controllers
Database.SaveChanges(); Database.SaveChanges();
} }
private void UpdateOnGenerateExpression(Disco.Models.Repository.DocumentTemplate documentTemplate, string OnGenerateExpression)
{
if (string.IsNullOrWhiteSpace(OnGenerateExpression))
{
documentTemplate.OnGenerateExpression = null;
}
else
{
documentTemplate.OnGenerateExpression = OnGenerateExpression.Trim();
}
// Invalidate Cache
documentTemplate.OnGenerateExpressionInvalidateCache();
Database.SaveChanges();
}
private void UpdateOnImportAttachmentExpression(Disco.Models.Repository.DocumentTemplate documentTemplate, string OnImportAttachmentExpression)
{
if (string.IsNullOrWhiteSpace(OnImportAttachmentExpression))
{
documentTemplate.OnImportAttachmentExpression = null;
}
else
{
documentTemplate.OnImportAttachmentExpression = OnImportAttachmentExpression.Trim();
}
// Invalidate Cache
documentTemplate.OnImportAttachmentExpressionInvalidateCache();
Database.SaveChanges();
}
private void UpdateFlattenForm(Disco.Models.Repository.DocumentTemplate documentTemplate, string FlattenForm) private void UpdateFlattenForm(Disco.Models.Repository.DocumentTemplate documentTemplate, string FlattenForm)
{ {
if (string.IsNullOrWhiteSpace(FlattenForm)) if (string.IsNullOrWhiteSpace(FlattenForm))
@@ -9,6 +9,7 @@
var canConfig = Authorization.Has(Claims.Config.DeviceProfile.Configure); var canConfig = Authorization.Has(Claims.Config.DeviceProfile.Configure);
var canConfigExpression = Authorization.Has(Claims.Config.DeviceProfile.ConfigureComputerNameTemplate); var canConfigExpression = Authorization.Has(Claims.Config.DeviceProfile.ConfigureComputerNameTemplate);
var canDelete = (Authorization.Has(Claims.Config.DeviceProfile.Delete) && Model.CanDelete); var canDelete = (Authorization.Has(Claims.Config.DeviceProfile.Delete) && Model.CanDelete);
var canViewPlugins = Authorization.Has(Claims.Config.Plugin.Install);
var hideAdvanced = var hideAdvanced =
Model.DeviceProfile.AssignedUsersLinkedGroup == null && Model.DeviceProfile.AssignedUsersLinkedGroup == null &&
@@ -18,6 +19,7 @@
{ {
Html.BundleDeferred("~/Style/Fancytree"); Html.BundleDeferred("~/Style/Fancytree");
Html.BundleDeferred("~/ClientScripts/Modules/jQuery-Fancytree"); Html.BundleDeferred("~/ClientScripts/Modules/jQuery-Fancytree");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
} }
} }
<div id="configurationDeviceProfileShow" class="form@(hideAdvanced ? " Config_HideAdvanced" : null)" style="width: 640px"> <div id="configurationDeviceProfileShow" class="form@(hideAdvanced ? " Config_HideAdvanced" : null)" style="width: 640px">
@@ -39,41 +41,12 @@
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var $Name = $('#DeviceProfile_Name'); document.DiscoFunctions.PropertyChangeHelper(
var $NameAjaxSave = $Name.next('.ajaxSave'); $('#DeviceProfile_Name'),
$Name 'Name',
.watermark('Profile Short Name') '@Url.Action(MVC.API.DeviceProfile.UpdateName(Model.DeviceProfile.Id))',
.focus(function () { $Name.select() }) 'ProfileName'
.keydown(function (e) { );
$NameAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$NameAjaxSave.hide();
})
.change(function () {
$NameAjaxSave.hide();
var $ajaxLoading = $NameAjaxSave.next('.ajaxLoading').show();
var data = { ProfileName: $Name.val() };
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateName(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update name: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update name: ' + textStatus);
$ajaxLoading.hide();
}
});
});
}); });
</script> </script>
} }
@@ -93,41 +66,12 @@
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var $ShortName = $('#DeviceProfile_ShortName'); document.DiscoFunctions.PropertyChangeHelper(
var $ShortNameAjaxSave = $ShortName.next('.ajaxSave'); $('#DeviceProfile_ShortName'),
$ShortName 'Short Name',
.watermark('Profile Short Name') '@Url.Action(MVC.API.DeviceProfile.UpdateShortName(Model.DeviceProfile.Id))',
.focus(function () { $ShortName.select() }) 'ShortName'
.keydown(function (e) { );
$ShortNameAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$ShortNameAjaxSave.hide();
})
.change(function () {
$ShortNameAjaxSave.hide();
var $ajaxLoading = $ShortNameAjaxSave.next('.ajaxLoading').show();
var data = { ShortName: $ShortName.val() };
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateShortName(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update short name: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update short name: ' + textStatus);
$ajaxLoading.hide();
}
});
});
}); });
</script> </script>
} }
@@ -142,46 +86,17 @@
</th> </th>
<td>@if (canConfig) <td>@if (canConfig)
{ {
@Html.TextBoxFor(model => model.DeviceProfile.Description) @Html.EditorFor(model => model.DeviceProfile.Description)
@AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var $Description = $('#DeviceProfile_Description'); document.DiscoFunctions.PropertyChangeHelper(
var $DescriptionAjaxSave = $Description.next('.ajaxSave'); $('#DeviceProfile_Description'),
$Description 'Description',
.watermark('Profile Description') '@Url.Action(MVC.API.DeviceProfile.UpdateDescription(Model.DeviceProfile.Id))',
.focus(function () { $Description.select() }) 'Description'
.keydown(function (e) { );
$DescriptionAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$DescriptionAjaxSave.hide();
})
.change(function () {
$DescriptionAjaxSave.hide();
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
var data = { Description: $Description.val() };
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateDescription(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update description: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update description: ' + textStatus);
$ajaxLoading.hide();
}
});
});
}); });
</script> </script>
} }
@@ -210,19 +125,12 @@
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DeviceProfile_DistributionType').change(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DeviceProfile_DistributionType'),
var $ajaxLoading = $this.next('.ajaxLoading').show(); null,
var data = { DistributionType: $this.val() }; '@Url.Action(MVC.API.DeviceProfile.UpdateDistributionType(Model.DeviceProfile.Id))',
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateDistributionType(Model.DeviceProfile.Id))', data, function (response, result) { 'DistributionType'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Distribution Type:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
@@ -241,19 +149,12 @@
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DeviceProfile_DefaultOrganisationAddress').change(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DeviceProfile_DefaultOrganisationAddress'),
var $ajaxLoading = $this.next('.ajaxLoading').show(); null,
var data = { DefaultOrganisationAddress: $this.val() }; '@Url.Action(MVC.API.DeviceProfile.UpdateDefaultOrganisationAddress(Model.DeviceProfile.Id))',
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateDefaultOrganisationAddress(Model.DeviceProfile.Id))', data, function (response, result) { 'DefaultOrganisationAddress'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Address:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
@@ -273,36 +174,18 @@
<tr> <tr>
<th>Allocate Certificates: <th>Allocate Certificates:
</th> </th>
<td>@if (canConfig) <td>@if (canConfig && Model.CertificateProviders.Count > 0)
{ {
@Html.DropDownListFor(model => model.DeviceProfile.CertificateProviderId, Model.CertificateProviders.ToSelectListItems(null, true, "Not Allocated")) @Html.DropDownListFor(model => model.DeviceProfile.CertificateProviderId, Model.CertificateProviders.ToSelectListItems(null, true, "Not Allocated"))
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var $field = $('#DeviceProfile_CertificateProviderId'); document.DiscoFunctions.PropertyChangeHelper(
var $ajaxLoading = $field.next('.ajaxLoading'); $('#DeviceProfile_CertificateProviderId'),
$field null,
.change(function () { '@Url.Action(MVC.API.DeviceProfile.UpdateCertificateProviderId(Model.DeviceProfile.Id))',
$ajaxLoading.show(); 'CertificateProviderId'
var data = { CertificateProviderId: $field.val() }; );
$.ajax({
url: '@Url.Action(MVC.API.DeviceProfile.UpdateCertificateProviderId(Model.DeviceProfile.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update Certificate Provider Id: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update Certificate Provider Id: ' + textStatus);
$ajaxLoading.hide();
}
});
});
}); });
</script> </script>
} }
@@ -325,6 +208,14 @@
} }
} }
} }
@if (canViewPlugins)
{
<div class="info-box">
<p class="fa-p">
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install certificate provider plugins.
</p>
</div>
}
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -333,46 +224,29 @@
</th> </th>
<td>@if (canConfig && canConfigExpression) <td>@if (canConfig && canConfigExpression)
{ {
@Html.TextBoxFor(model => model.DeviceProfile.ComputerNameTemplate) @Html.EditorFor(model => model.DeviceProfile.ComputerNameTemplate)
@AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<a id="expressionBrowserAnchor" href="@(Url.Action(MVC.Config.DocumentTemplate.ExpressionBrowser()))">&nbsp;</a> <a id="expressionBrowserAnchor" href="@(Url.Action(MVC.Config.DocumentTemplate.ExpressionBrowser()))">&nbsp;</a>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var $ComputerNameTemplate = $('#DeviceProfile_ComputerNameTemplate'); var field = $('#DeviceProfile_ComputerNameTemplate');
var $ajaxSave = $ComputerNameTemplate.next('.ajaxSave'); var fieldOriginalWidth, fieldOriginalHeight;
$ComputerNameTemplate
.focus(function () { $ComputerNameTemplate.select() }) document.DiscoFunctions.PropertyChangeHelper(
.keydown(function (e) { field,
$ajaxSave.show(); 'None',
if (e.which == 13) { '@Url.Action(MVC.API.DeviceProfile.UpdateComputerNameTemplate(Model.DeviceProfile.Id))',
$(this).blur(); 'ComputerNameTemplate'
} );
}).blur(function () {
$ajaxSave.hide(); field.focus(function () {
}) fieldOriginalWidth = field.width();
.change(function () { fieldOriginalHeight = field.height();
$ajaxSave.hide(); field.css('overflow', 'visible').animate({ width: field.parent().width() - 52, height: 75 }, 200);
var $ajaxLoading = $ajaxSave.next('.ajaxLoading').show(); }).blur(function () {
var data = { ComputerNameTemplate: $ComputerNameTemplate.val() }; field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
$.ajax({ }).attr('placeholder', 'None').attr('spellcheck', 'false');
url: '@(Url.Action(MVC.API.DeviceProfile.UpdateComputerNameTemplate(Model.DeviceProfile.Id)))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update computer name template: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update computer name template: ' + textStatus);
$ajaxLoading.hide();
}
});
});
}); });
</script> </script>
} }
@@ -395,19 +269,12 @@
<input id="DeviceProfile_EnforceComputerNameConvention" type="checkbox" @(Model.DeviceProfile.EnforceComputerNameConvention ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/> <input id="DeviceProfile_EnforceComputerNameConvention" type="checkbox" @(Model.DeviceProfile.EnforceComputerNameConvention ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DeviceProfile_EnforceComputerNameConvention').click(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DeviceProfile_EnforceComputerNameConvention'),
var $ajaxLoading = $this.nextAll('.ajaxLoading').show(); null,
var data = { EnforceComputerNameConvention: $this.is(':checked') }; '@Url.Action(MVC.API.DeviceProfile.UpdateEnforceComputerNameConvention(Model.DeviceProfile.Id))',
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateEnforceComputerNameConvention(Model.DeviceProfile.Id))', data, function (response, result) { 'EnforceComputerNameConvention'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Enforce Computer Name Convention:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
@@ -434,19 +301,12 @@
<input id="DeviceProfile_ProvisionADAccount" type="checkbox" @(Model.DeviceProfile.ProvisionADAccount ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/> <input id="DeviceProfile_ProvisionADAccount" type="checkbox" @(Model.DeviceProfile.ProvisionADAccount ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DeviceProfile_ProvisionADAccount').click(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DeviceProfile_ProvisionADAccount'),
var $ajaxLoading = $this.nextAll('.ajaxLoading').show(); null,
var data = { ProvisionADAccount: $this.is(':checked') }; '@Url.Action(MVC.API.DeviceProfile.UpdateProvisionADAccount(Model.DeviceProfile.Id))',
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateProvisionADAccount(Model.DeviceProfile.Id))', data, function (response, result) { 'ProvisionADAccount'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Provision AD Account:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
@@ -465,19 +325,12 @@
<input id="DeviceProfile_AssignedUserLocalAdmin" type="checkbox" @(Model.DeviceProfile.AssignedUserLocalAdmin ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/> <input id="DeviceProfile_AssignedUserLocalAdmin" type="checkbox" @(Model.DeviceProfile.AssignedUserLocalAdmin ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DeviceProfile_AssignedUserLocalAdmin').click(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DeviceProfile_AssignedUserLocalAdmin'),
var $ajaxLoading = $this.nextAll('.ajaxLoading').show(); null,
var data = { AssignedUserLocalAdmin: $this.is(':checked') }; '@Url.Action(MVC.API.DeviceProfile.UpdateAssignedUserLocalAdmin(Model.DeviceProfile.Id))',
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateAssignedUserLocalAdmin(Model.DeviceProfile.Id))', data, function (response, result) { 'AssignedUserLocalAdmin'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Assigned User Is Local Administrator:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
@@ -496,19 +349,12 @@
<input id="DeviceProfile_AllowUntrustedReimageJobEnrolment" type="checkbox" @(Model.DeviceProfile.AllowUntrustedReimageJobEnrolment ? new MvcHtmlString("checked=\"checked\" ") : null)/> <input id="DeviceProfile_AllowUntrustedReimageJobEnrolment" type="checkbox" @(Model.DeviceProfile.AllowUntrustedReimageJobEnrolment ? new MvcHtmlString("checked=\"checked\" ") : null)/>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DeviceProfile_AllowUntrustedReimageJobEnrolment').click(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DeviceProfile_AllowUntrustedReimageJobEnrolment'),
var $ajaxLoading = $this.nextAll('.ajaxLoading').show(); null,
var data = { AllowUntrustedReimageJobEnrolment: $this.is(':checked') }; '@Url.Action(MVC.API.DeviceProfile.UpdateAllowUntrustedReimageJobEnrolment(Model.DeviceProfile.Id))',
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateAllowUntrustedReimageJobEnrolment(Model.DeviceProfile.Id))', data, function (response, result) { 'AllowUntrustedReimageJobEnrolment'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Allow Untrusted Reimage Job Enrolment:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
@@ -668,19 +514,12 @@
<input id="DeviceProfile_EnforceOrganisationalUnit" type="checkbox" @(Model.DeviceProfile.EnforceOrganisationalUnit ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/> <input id="DeviceProfile_EnforceOrganisationalUnit" type="checkbox" @(Model.DeviceProfile.EnforceOrganisationalUnit ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DeviceProfile_EnforceOrganisationalUnit').click(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DeviceProfile_EnforceOrganisationalUnit'),
var $ajaxLoading = $this.nextAll('.ajaxLoading').show(); null,
var data = { EnforceOrganisationalUnit: $this.is(':checked') }; '@Url.Action(MVC.API.DeviceProfile.UpdateEnforceOrganisationalUnit(Model.DeviceProfile.Id))',
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateEnforceOrganisationalUnit(Model.DeviceProfile.Id))', data, function (response, result) { 'EnforceOrganisationalUnit'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Enforce Organisation Unit:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
File diff suppressed because it is too large Load Diff
@@ -35,12 +35,12 @@
<h3 data-bind="text: title"></h3> <h3 data-bind="text: title"></h3>
<div data-bind="visible: undetected"> <div data-bind="visible: undetected">
Disco QR-Code not found<br /> Disco QR-Code not found<br />
<a target="_blank" data-bind="attr: { href: manuallyAssignUrl }, visible: $parent.sessionEnded">Manually Assign Page</a> <a target="_blank" href="#" data-bind="attr: { href: manuallyAssignUrl }, visible: $parent.sessionEnded">Manually Assign Page</a>
</div> </div>
<div data-bind="visible: detected"> <div data-bind="visible: detected">
Document: <a target="_blank" data-bind="text: documentTemplate, attr: { href: documentTemplateUrl }"></a> Document: <a target="_blank" href="#" data-bind="text: documentTemplate, attr: { href: documentTemplateUrl }"></a>
<br /> <br />
Target: <a target="_blank" data-bind="text: assignedData, attr: { href: assignedDataUrl }"></a> Target: <a target="_blank" href="#" data-bind="text: assignedData, attr: { href: assignedDataUrl }"></a>
</div> </div>
<div data-bind="visible: !(detected() || undetected())"> <div data-bind="visible: !(detected() || undetected())">
<p class="sessionStatus" data-bind="text: progressStatus"> <p class="sessionStatus" data-bind="text: progressStatus">
@@ -306,7 +306,7 @@
logHub = $.connection.logNotifications; logHub = $.connection.logNotifications;
logHub.client.receiveLog = parseLog logHub.client.receiveLog = parseLog
$.connection.hub.qs = { LogModules: '@(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName)' }; $.connection.hub.qs = { LogModules: '@(Disco.BI.DocumentTemplateBI.DocumentsLog.Current.LiveLogGroupName)' };
$.connection.hub.error(function (error) { $.connection.hub.error(function (error) {
alert('Live-Log Error: ' + error); alert('Live-Log Error: ' + error);
}); });
@@ -144,6 +144,8 @@ WriteLiteral(">\r\n Disco QR-Code not found<br />\r\n
WriteLiteral(" target=\"_blank\""); WriteLiteral(" target=\"_blank\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" data-bind=\"attr: { href: manuallyAssignUrl }, visible: $parent.sessionEnded\""); WriteLiteral(" data-bind=\"attr: { href: manuallyAssignUrl }, visible: $parent.sessionEnded\"");
WriteLiteral(">Manually Assign Page</a>\r\n </div>\r\n " + WriteLiteral(">Manually Assign Page</a>\r\n </div>\r\n " +
@@ -155,6 +157,8 @@ WriteLiteral(">\r\n Document: <a");
WriteLiteral(" target=\"_blank\""); WriteLiteral(" target=\"_blank\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" data-bind=\"text: documentTemplate, attr: { href: documentTemplateUrl }\""); WriteLiteral(" data-bind=\"text: documentTemplate, attr: { href: documentTemplateUrl }\"");
WriteLiteral("></a>\r\n <br />\r\n Target: <a" + WriteLiteral("></a>\r\n <br />\r\n Target: <a" +
@@ -162,6 +166,8 @@ WriteLiteral("></a>\r\n <br />\r\n
WriteLiteral(" target=\"_blank\""); WriteLiteral(" target=\"_blank\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" data-bind=\"text: assignedData, attr: { href: assignedDataUrl }\""); WriteLiteral(" data-bind=\"text: assignedData, attr: { href: assignedDataUrl }\"");
WriteLiteral("></a>\r\n </div>\r\n <div"); WriteLiteral("></a>\r\n </div>\r\n <div");
@@ -460,7 +466,7 @@ WriteLiteral(@"',
#line 309 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 309 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName); Write(Disco.BI.DocumentTemplateBI.DocumentsLog.Current.LiveLogGroupName);
#line default #line default
@@ -11,6 +11,8 @@
Model.DocumentTemplate.UsersLinkedGroup == null && Model.DocumentTemplate.UsersLinkedGroup == null &&
Model.DocumentTemplate.DevicesLinkedGroup == null && Model.DocumentTemplate.DevicesLinkedGroup == null &&
Model.DocumentTemplate.FilterExpression == null && Model.DocumentTemplate.FilterExpression == null &&
Model.DocumentTemplate.OnGenerateExpression == null &&
Model.DocumentTemplate.OnImportAttachmentExpression == null &&
Model.TemplateExpressions.All(e => e.All(p => !p.ParseError)); Model.TemplateExpressions.All(e => e.All(p => !p.ParseError));
#region Can Bulk Generate #region Can Bulk Generate
@@ -35,6 +37,11 @@
#endregion #endregion
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description); ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description);
if (canConfig)
{
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
}
} }
<div id="Config_DocumentTemplates_Show" class="@(hideAdvanced ? "Config_HideAdvanced" : null)"> <div id="Config_DocumentTemplates_Show" class="@(hideAdvanced ? "Config_HideAdvanced" : null)">
<div class="form" style="width: 650px; margin: 10px auto 20px;"> <div class="form" style="width: 650px; margin: 10px auto 20px;">
@@ -63,41 +70,12 @@
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var $Description = $('#DocumentTemplate_Description'); document.DiscoFunctions.PropertyChangeHelper(
var $DescriptionAjaxSave = $Description.next('.ajaxSave'); $('#DocumentTemplate_Description'),
$Description 'Description',
.watermark('Description') '@Url.Action(MVC.API.DocumentTemplate.UpdateDescription(Model.DocumentTemplate.Id))',
.focus(function () { $Description.select() }) 'Description'
.keydown(function (e) { );
$DescriptionAjaxSave.show();
if (e.which == 13) {
$(this).blur();
}
}).blur(function () {
$DescriptionAjaxSave.hide();
})
.change(function () {
$DescriptionAjaxSave.hide();
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
var data = { Description: $Description.val() };
$.ajax({
url: '@Url.Action(MVC.API.DocumentTemplate.UpdateDescription(Model.DocumentTemplate.Id))',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
} else {
$ajaxLoading.hide();
alert('Unable to update description: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update description: ' + textStatus);
$ajaxLoading.hide();
}
});
});
}); });
</script> </script>
} }
@@ -123,19 +101,12 @@
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
$('#DocumentTemplate_FlattenForm').click(function () { document.DiscoFunctions.PropertyChangeHelper(
var $this = $(this); $('#DocumentTemplate_FlattenForm'),
var $ajaxLoading = $this.next('.ajaxLoading').show(); null,
var data = { FlattenForm: $this.is(':checked') }; '@Url.Action(MVC.API.DocumentTemplate.UpdateFlattenForm(Model.DocumentTemplate.Id))',
$.getJSON('@(Url.Action(MVC.API.DocumentTemplate.UpdateFlattenForm(Model.DocumentTemplate.Id)))', data, function (response, result) { 'FlattenForm'
if (result != 'success' || response != 'OK') { );
alert('Unable to change Flatten Form:\n' + response);
$ajaxLoading.hide();
} else {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
}
});
});
}); });
</script> </script>
} }
@@ -429,54 +400,46 @@
</th> </th>
<td>@if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression)) <td>@if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression))
{ {
@Html.TextBoxFor(model => model.DocumentTemplate.FilterExpression) @Html.EditorFor(model => model.DocumentTemplate.FilterExpression)
@AjaxHelpers.AjaxRemove() @AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader() @AjaxHelpers.AjaxLoader()
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var $FilterExpression = $('#DocumentTemplate_FilterExpression'); var field = $('#DocumentTemplate_FilterExpression');
var $ajaxLoading = $FilterExpression.nextAll('.ajaxLoading').first(); var fieldRemove = field.next('.ajaxRemove');
var $ajaxRemove = $FilterExpression.nextAll('.ajaxRemove').first(); var fieldOriginalWidth, fieldOriginalHeight;
$FilterExpression
.watermark('Filter Expression') document.DiscoFunctions.PropertyChangeHelper(
.focus(function () { $FilterExpression.select() }) field,
.keydown(function (e) { 'None',
if (e.which == 13) { '@Url.Action(MVC.API.DocumentTemplate.UpdateFilterExpression(Model.DocumentTemplate.Id))',
$(this).blur(); 'FilterExpression'
} );
}).change(function () {
updateFilterExpression($FilterExpression.val()); field.focus(function () {
}); fieldOriginalWidth = field.width();
if ($FilterExpression.val() != '') fieldOriginalHeight = field.height();
$ajaxRemove.show(); field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
$ajaxRemove.click(function () { }).blur(function () {
updateFilterExpression(''); field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
$FilterExpression.val(''); }).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
}); });
var updateFilterExpression = function (filterExpression) {
$ajaxLoading.show(); if (!!field.val()) {
$ajaxRemove.hide(); fieldRemove.show();
var data = { FilterExpression: filterExpression }; } else {
$.ajax({ fieldRemove.hide();
url: '@Url.Action(MVC.API.DocumentTemplate.UpdateFilterExpression(Model.DocumentTemplate.Id))', }
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
if (data.FilterExpression != '')
$ajaxRemove.fadeIn('fast');
} else {
$ajaxLoading.hide();
alert('Unable to update filter expression: ' + d);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to update filter expression: ' + textStatus);
$ajaxLoading.hide();
}
});
};
}); });
</script> </script>
} }
@@ -493,6 +456,147 @@
</div> </div>
} }
} }
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated to determine if this template is shown in the <em>Generate Document</em> drop-down list.
</p>
</div>
</td>
</tr>
<tr>
<th>On Generated Expression:
</th>
<td>@if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression))
{
@Html.EditorFor(model => model.DocumentTemplate.OnGenerateExpression)
@AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var field = $('#DocumentTemplate_OnGenerateExpression');
var fieldRemove = field.next('.ajaxRemove');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DocumentTemplate.UpdateOnGenerateExpression(Model.DocumentTemplate.Id))',
'OnGenerateExpression'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
});
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
});
</script>
}
else
{
if (string.IsNullOrWhiteSpace(Model.DocumentTemplate.OnGenerateExpression))
{
<span class="smallMessage">&lt;None Specified&gt;</span>
}
else
{
<div class="code">
@Model.DocumentTemplate.OnGenerateExpression
</div>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated each time a document is generated from this template.
</p>
</div>
</td>
</tr>
<tr>
<th>On Import Expression:
</th>
<td>@if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression))
{
@Html.EditorFor(model => model.DocumentTemplate.OnImportAttachmentExpression)
@AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var field = $('#DocumentTemplate_OnImportAttachmentExpression');
var fieldRemove = field.next('.ajaxRemove');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DocumentTemplate.UpdateOnImportAttachmentExpression(Model.DocumentTemplate.Id))',
'OnImportAttachmentExpression'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
});
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
});
</script>
}
else
{
if (string.IsNullOrWhiteSpace(Model.DocumentTemplate.OnImportAttachmentExpression))
{
<span class="smallMessage">&lt;None Specified&gt;</span>
}
else
{
<div class="code">
@Model.DocumentTemplate.OnImportAttachmentExpression
</div>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated each time a document is imported (as an attachment) where it is determined the document was based on this template.
</p>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
File diff suppressed because it is too large Load Diff
@@ -61,7 +61,9 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
if (PropertyField[0].nodeName.toLowerCase() == 'textarea') { if (PropertyField[0].nodeName.toLowerCase() == 'textarea') {
PropertyField.keydown(function () { PropertyField.keydown(function () {
$ajaxSave.show(); $ajaxSave.show();
}) }).blur(function () {
$ajaxSave.hide();
});
} }
} }
}; };
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -60,7 +60,9 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
if (PropertyField[0].nodeName.toLowerCase() == 'textarea') { if (PropertyField[0].nodeName.toLowerCase() == 'textarea') {
PropertyField.keydown(function () { PropertyField.keydown(function () {
$ajaxSave.show(); $ajaxSave.show();
}) }).blur(function () {
$ajaxSave.hide();
});
} }
} }
}; };
+14 -2
View File
@@ -287,8 +287,12 @@ table.deviceProfileTable th.type {
table.deviceProfileTable th.deviceCount { table.deviceProfileTable th.deviceCount {
width: 120px; width: 120px;
} }
#configurationDeviceProfileShow #ComputerNameTemplate { #configurationDeviceProfileShow #DeviceProfile_ComputerNameTemplate {
width: 300px; height: 16px;
min-height: 16px;
width: calc(100% - 32px);
overflow: hidden;
font-family: Consolas, "Courier New", monospace;
} }
#configurationDeviceProfileShow #expressionBrowserAnchor { #configurationDeviceProfileShow #expressionBrowserAnchor {
display: inline-block; display: inline-block;
@@ -622,6 +626,14 @@ div.logEventsViewport table.logEventsViewport > tbody > tr > td.eventType {
#Config_DocumentTemplates_Show > div.form > table > tbody > tr > th { #Config_DocumentTemplates_Show > div.form > table > tbody > tr > th {
width: 140px; width: 140px;
} }
#Config_DocumentTemplates_Show #DocumentTemplate_FilterExpression,
#Config_DocumentTemplates_Show #DocumentTemplate_OnGenerateExpression,
#Config_DocumentTemplates_Show #DocumentTemplate_OnImportAttachmentExpression {
height: 16px;
min-height: 16px;
overflow: hidden;
font-family: Consolas, "Courier New", monospace;
}
#Config_DocumentTemplates_Show #Config_DocumentTemplates_Scope_Button { #Config_DocumentTemplates_Show #Config_DocumentTemplates_Scope_Button {
margin-top: 4px; margin-top: 4px;
} }
+13 -2
View File
@@ -228,8 +228,12 @@ table.deviceProfileTable {
} }
#configurationDeviceProfileShow { #configurationDeviceProfileShow {
#ComputerNameTemplate { #DeviceProfile_ComputerNameTemplate {
width: 300px; height: 16px;
min-height: 16px;
width: calc(~"100% - 32px");
overflow: hidden;
font-family: @FontFamilyMono;
} }
#expressionBrowserAnchor { #expressionBrowserAnchor {
@@ -656,6 +660,13 @@ div.logEventsViewport {
width: 140px; width: 140px;
} }
#DocumentTemplate_FilterExpression, #DocumentTemplate_OnGenerateExpression, #DocumentTemplate_OnImportAttachmentExpression {
height: 16px;
min-height: 16px;
overflow: hidden;
font-family: @FontFamilyMono;
}
#Config_DocumentTemplates_Scope_Button { #Config_DocumentTemplates_Scope_Button {
margin-top: 4px; margin-top: 4px;
} }
File diff suppressed because one or more lines are too long
@@ -83,6 +83,18 @@ namespace Disco.Web.Areas.API.Controllers
} }
[NonAction] [NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateOnGenerateExpression()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnGenerateExpression);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateOnImportAttachmentExpression()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnImportAttachmentExpression);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult UpdateFlattenForm() public virtual System.Web.Mvc.ActionResult UpdateFlattenForm()
{ {
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateFlattenForm); return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateFlattenForm);
@@ -173,6 +185,8 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string Template = "Template"; public readonly string Template = "Template";
public readonly string UpdateDescription = "UpdateDescription"; public readonly string UpdateDescription = "UpdateDescription";
public readonly string UpdateFilterExpression = "UpdateFilterExpression"; public readonly string UpdateFilterExpression = "UpdateFilterExpression";
public readonly string UpdateOnGenerateExpression = "UpdateOnGenerateExpression";
public readonly string UpdateOnImportAttachmentExpression = "UpdateOnImportAttachmentExpression";
public readonly string UpdateFlattenForm = "UpdateFlattenForm"; public readonly string UpdateFlattenForm = "UpdateFlattenForm";
public readonly string UpdateScope = "UpdateScope"; public readonly string UpdateScope = "UpdateScope";
public readonly string UpdateJobSubTypes = "UpdateJobSubTypes"; public readonly string UpdateJobSubTypes = "UpdateJobSubTypes";
@@ -195,6 +209,8 @@ namespace Disco.Web.Areas.API.Controllers
public const string Template = "Template"; public const string Template = "Template";
public const string UpdateDescription = "UpdateDescription"; public const string UpdateDescription = "UpdateDescription";
public const string UpdateFilterExpression = "UpdateFilterExpression"; public const string UpdateFilterExpression = "UpdateFilterExpression";
public const string UpdateOnGenerateExpression = "UpdateOnGenerateExpression";
public const string UpdateOnImportAttachmentExpression = "UpdateOnImportAttachmentExpression";
public const string UpdateFlattenForm = "UpdateFlattenForm"; public const string UpdateFlattenForm = "UpdateFlattenForm";
public const string UpdateScope = "UpdateScope"; public const string UpdateScope = "UpdateScope";
public const string UpdateJobSubTypes = "UpdateJobSubTypes"; public const string UpdateJobSubTypes = "UpdateJobSubTypes";
@@ -252,6 +268,26 @@ namespace Disco.Web.Areas.API.Controllers
public readonly string FilterExpression = "FilterExpression"; public readonly string FilterExpression = "FilterExpression";
public readonly string redirect = "redirect"; public readonly string redirect = "redirect";
} }
static readonly ActionParamsClass_UpdateOnGenerateExpression s_params_UpdateOnGenerateExpression = new ActionParamsClass_UpdateOnGenerateExpression();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateOnGenerateExpression UpdateOnGenerateExpressionParams { get { return s_params_UpdateOnGenerateExpression; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_UpdateOnGenerateExpression
{
public readonly string id = "id";
public readonly string OnGenerateExpression = "OnGenerateExpression";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_UpdateOnImportAttachmentExpression s_params_UpdateOnImportAttachmentExpression = new ActionParamsClass_UpdateOnImportAttachmentExpression();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateOnImportAttachmentExpression UpdateOnImportAttachmentExpressionParams { get { return s_params_UpdateOnImportAttachmentExpression; } }
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionParamsClass_UpdateOnImportAttachmentExpression
{
public readonly string id = "id";
public readonly string OnImportAttachmentExpression = "OnImportAttachmentExpression";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_UpdateFlattenForm s_params_UpdateFlattenForm = new ActionParamsClass_UpdateFlattenForm(); static readonly ActionParamsClass_UpdateFlattenForm s_params_UpdateFlattenForm = new ActionParamsClass_UpdateFlattenForm();
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ActionParamsClass_UpdateFlattenForm UpdateFlattenFormParams { get { return s_params_UpdateFlattenForm; } } public ActionParamsClass_UpdateFlattenForm UpdateFlattenFormParams { get { return s_params_UpdateFlattenForm; } }
@@ -457,6 +493,34 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo; return callInfo;
} }
[NonAction]
partial void UpdateOnGenerateExpressionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string OnGenerateExpression, bool redirect);
[NonAction]
public override System.Web.Mvc.ActionResult UpdateOnGenerateExpression(string id, string OnGenerateExpression, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnGenerateExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "OnGenerateExpression", OnGenerateExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
UpdateOnGenerateExpressionOverride(callInfo, id, OnGenerateExpression, redirect);
return callInfo;
}
[NonAction]
partial void UpdateOnImportAttachmentExpressionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string OnImportAttachmentExpression, bool redirect);
[NonAction]
public override System.Web.Mvc.ActionResult UpdateOnImportAttachmentExpression(string id, string OnImportAttachmentExpression, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnImportAttachmentExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "OnImportAttachmentExpression", OnImportAttachmentExpression);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
UpdateOnImportAttachmentExpressionOverride(callInfo, id, OnImportAttachmentExpression, redirect);
return callInfo;
}
[NonAction] [NonAction]
partial void UpdateFlattenFormOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string FlattenForm, bool redirect); partial void UpdateFlattenFormOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string FlattenForm, bool redirect);