Permissions & Authorization for Users #24

Initial Release; Includes Database and MVC refactoring
This commit is contained in:
Gary Sharp
2013-10-10 19:13:16 +11:00
parent 172ce5524a
commit a099d68915
458 changed files with 40221 additions and 12130 deletions
@@ -16,7 +16,7 @@ namespace Disco.BI.DocumentTemplateBI
{
private static ConcurrentDictionary<string, List<RectangleF>> _Cache = new ConcurrentDictionary<string, List<RectangleF>>();
public static List<RectangleF> GetLocations(DocumentTemplate dt, DiscoDataContext dbContext)
public static List<RectangleF> GetLocations(DocumentTemplate dt, DiscoDataContext Database)
{
// Check Cache
List<RectangleF> locations;
@@ -25,7 +25,7 @@ namespace Disco.BI.DocumentTemplateBI
return locations;
}
// Generate Cache
return GenerateLocations(dt, dbContext);
return GenerateLocations(dt, Database);
}
public static bool InvalidateLocations(DocumentTemplate dt)
@@ -47,9 +47,9 @@ namespace Disco.BI.DocumentTemplateBI
return _Cache.TryAdd(DocumentTemplateId, Locations);
}
internal static List<RectangleF> GenerateLocations(DocumentTemplate dt, DiscoDataContext dbContext)
internal static List<RectangleF> GenerateLocations(DocumentTemplate dt, DiscoDataContext Database)
{
string templateFilename = dt.RepositoryFilename(dbContext);
string templateFilename = dt.RepositoryFilename(Database);
PdfReader pdfReader = new PdfReader(templateFilename);
List<RectangleF> locations = new List<RectangleF>();
@@ -115,7 +115,7 @@ namespace Disco.BI.DocumentTemplateBI
}
throw new System.ArgumentException(string.Format("Invalid Document Unique Identifier Version ({0})", s[1]), "UniqueIdentifier");
}
public bool LoadComponents(DiscoDataContext Context)
public bool LoadComponents(DiscoDataContext Database)
{
bool LoadComponents;
if (!this._loadedComponentsOk.HasValue)
@@ -142,7 +142,7 @@ namespace Disco.BI.DocumentTemplateBI
}
else
{
this._documentTemplate = Context.DocumentTemplates.Find(this.TemplateTypeId);
this._documentTemplate = Database.DocumentTemplates.Find(this.TemplateTypeId);
if (this._documentTemplate != null)
{
scopeType = this._documentTemplate.Scope;
@@ -158,7 +158,7 @@ namespace Disco.BI.DocumentTemplateBI
switch (scopeType)
{
case DocumentTemplate.DocumentTemplateScopes.Device:
Device d = Context.Devices.Find(this.DataId);
Device d = Database.Devices.Find(this.DataId);
if (d != null)
{
this._data = d;
@@ -169,7 +169,7 @@ namespace Disco.BI.DocumentTemplateBI
}
break;
case DocumentTemplate.DocumentTemplateScopes.Job:
Job i = Context.Jobs.Find(int.Parse(this.DataId));
Job i = Database.Jobs.Find(int.Parse(this.DataId));
if (i != null)
{
this._data = i;
@@ -180,7 +180,7 @@ namespace Disco.BI.DocumentTemplateBI
}
break;
case DocumentTemplate.DocumentTemplateScopes.User:
User u = Context.Users.Find(this.DataId);
User u = Database.Users.Find(this.DataId);
if (u != null)
{
this._data = u;
@@ -16,15 +16,15 @@ namespace Disco.BI.DocumentTemplateBI.Importer
public const string WatcherFilter = "*.pdf";
public string DropBoxLocation { get; private set; }
public DocumentDropBoxMonitor(DiscoDataContext Context, ISchedulerFactory SchedulerFactory, Cache HttpCache)
public DocumentDropBoxMonitor(DiscoDataContext Database, ISchedulerFactory SchedulerFactory, Cache HttpCache)
{
if (Context == null)
if (Database == null)
throw new System.ArgumentNullException("Context");
this._httpCache = HttpCache;
var location = DataStore.CreateLocation(Context, "DocumentDropBox");
var location = DataStore.CreateLocation(Database, "DocumentDropBox");
this.DropBoxLocation = location.EndsWith(@"\") ? location : string.Concat(location, @"\");
this._scheduler = SchedulerFactory.GetScheduler();
@@ -13,7 +13,7 @@ namespace Disco.BI.DocumentTemplateBI.Importer
public override bool SingleInstanceTask { get { return true; } }
public override bool CancelInitiallySupported { get { return false; } }
public override void InitalizeScheduledTask(DiscoDataContext dbContext)
public override void InitalizeScheduledTask(DiscoDataContext Database)
{
// Trigger Daily @ 12:30am
TriggerBuilder triggerBuilder = TriggerBuilder.Create().WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 30));
@@ -24,9 +24,9 @@ namespace Disco.BI.DocumentTemplateBI.Importer
protected override void ExecuteTask()
{
string dataStoreLocation;
using (DiscoDataContext dbContext = new DiscoDataContext())
using (DiscoDataContext database = new DiscoDataContext())
{
dataStoreLocation = DataStore.CreateLocation(dbContext, "Cache\\DocumentDropBox_SessionPages");
dataStoreLocation = DataStore.CreateLocation(database, "Cache\\DocumentDropBox_SessionPages");
}
int deleteCount = 0;
@@ -40,12 +40,12 @@ namespace Disco.BI.DocumentTemplateBI.Importer
try
{
using (DiscoDataContext dbContext = new DiscoDataContext())
using (DiscoDataContext database = new DiscoDataContext())
{
if (retryCount < 18)
{
context.JobDetail.JobDataMap["RetryCount"] = (++retryCount);
bool processResult = Interop.Pdf.PdfImporter.ProcessPdfAttachment(filename, dbContext, sessionId, httpCache);
bool processResult = Interop.Pdf.PdfImporter.ProcessPdfAttachment(filename, database, sessionId, httpCache);
if (processResult)
{
@@ -60,7 +60,7 @@ namespace Disco.BI.DocumentTemplateBI.Importer
{
try
{
string folderError = DataStore.CreateLocation(dbContext, "DocumentDropBox_Errors");
string folderError = DataStore.CreateLocation(database, "DocumentDropBox_Errors");
string filenameError = Path.Combine(folderError, Path.GetFileName(filename));
int filenameErrorCount = 0;
while (File.Exists(filenameError))
@@ -85,7 +85,7 @@ namespace Disco.BI.DocumentTemplateBI.Importer
{
try
{
string folderError = DataStore.CreateLocation(dbContext, "DocumentDropBox_Errors");
string folderError = DataStore.CreateLocation(database, "DocumentDropBox_Errors");
string filenameError = Path.Combine(folderError, Path.GetFileName(filename));
int filenameErrorCount = 0;
while (File.Exists(filenameError))