diff --git a/Disco.Configuration/Disco.Configuration.vbproj b/Disco.Configuration/Disco.Configuration.vbproj deleted file mode 100644 index c0e685e6..00000000 --- a/Disco.Configuration/Disco.Configuration.vbproj +++ /dev/null @@ -1,116 +0,0 @@ - - - - Debug - AnyCPU - - - - - {CD7BB28C-B74D-4880-8B7E-4487AB5E6AFC} - Library - Disco.Configuration - Disco.Configuration - 512 - Windows - v4.0 - - - true - full - true - true - bin\Debug\ - Disco.Configuration.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - pdbonly - false - true - true - bin\Release\ - Disco.Configuration.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - - - - - True - Application.myapp - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - {40F222A9-CC05-4035-AFF4-15A78250EF2B} - Disco.Models - - - - - \ No newline at end of file diff --git a/Disco.Configuration/My Project/Application.Designer.vb b/Disco.Configuration/My Project/Application.Designer.vb deleted file mode 100644 index 6b885653..00000000 --- a/Disco.Configuration/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.235 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/Disco.Configuration/My Project/Application.myapp b/Disco.Configuration/My Project/Application.myapp deleted file mode 100644 index 758895de..00000000 --- a/Disco.Configuration/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 1 - true - diff --git a/Disco.Configuration/My Project/AssemblyInfo.vb b/Disco.Configuration/My Project/AssemblyInfo.vb deleted file mode 100644 index 2b667b73..00000000 --- a/Disco.Configuration/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' General Information about an assembly is controlled through the following -' set of attributes. Change these attribute values to modify the information -' associated with an assembly. - -' Review the values of the assembly attributes - - - - - - - - - - -'The following GUID is for the ID of the typelib if this project is exposed to COM - - -' Version information for an assembly consists of the following four values: -' -' Major Version -' Minor Version -' Build Number -' Revision -' -' You can specify all the values or you can default the Build and Revision Numbers -' by using the '*' as shown below: -' - - - diff --git a/Disco.Configuration/My Project/Resources.Designer.vb b/Disco.Configuration/My Project/Resources.Designer.vb deleted file mode 100644 index d6f10bb4..00000000 --- a/Disco.Configuration/My Project/Resources.Designer.vb +++ /dev/null @@ -1,62 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.235 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Disco.Configuration.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set(ByVal value As Global.System.Globalization.CultureInfo) - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/Disco.Configuration/My Project/Resources.resx b/Disco.Configuration/My Project/Resources.resx deleted file mode 100644 index af7dbebb..00000000 --- a/Disco.Configuration/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Disco.Configuration/My Project/Settings.Designer.vb b/Disco.Configuration/My Project/Settings.Designer.vb deleted file mode 100644 index 7cf5ba83..00000000 --- a/Disco.Configuration/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.235 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.Disco.Configuration.My.MySettings - Get - Return Global.Disco.Configuration.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/Disco.Configuration/My Project/Settings.settings b/Disco.Configuration/My Project/Settings.settings deleted file mode 100644 index 85b890b3..00000000 --- a/Disco.Configuration/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Disco.Logging/App.config b/Disco.Logging/App.config deleted file mode 100644 index c4747432..00000000 --- a/Disco.Logging/App.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - -
- - - - - - - - - \ No newline at end of file diff --git a/Disco.Logging/Disco.Logging.csproj b/Disco.Logging/Disco.Logging.csproj deleted file mode 100644 index 8ac908b5..00000000 --- a/Disco.Logging/Disco.Logging.csproj +++ /dev/null @@ -1,125 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {BD16C575-70C2-4DDE-A572-FC79EF028CB2} - Library - Properties - Disco.Logging - Disco.Logging - v4.0 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - ..\packages\EntityFramework.4.3.1\lib\net40\EntityFramework.dll - - - ..\..\Resources\Libraries\fastJSON\fastJSON.dll - - - True - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - False - ..\packages\Newtonsoft.Json.4.5.1\lib\net40\Newtonsoft.Json.dll - - - ..\..\Resources\Libraries\Quartz\Quartz.dll - - - False - ..\packages\SignalR.Server.0.4.0.0\lib\net40\SignalR.dll - - - ..\packages\SignalR.Hosting.AspNet.0.4.0.0\lib\net40\SignalR.Hosting.AspNet.dll - - - - - - - True - ..\packages\SqlServerCompact.4.0.8482.1\lib\System.Data.SqlServerCe.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - {85A6BD19-2C64-4746-8F2C-A68A86E8C2D7} - Disco.Data - - - {FBC05512-FCCA-4B16-9E76-8C413C5DE6C9} - Disco.Models - - - - - - - - - - - - - - -REM if not exist "$(TargetDir)x86" md "$(TargetDir)x86" -REM xcopy /s /y "$(SolutionDir)packages\SqlServerCompact.4.0.8482.1\NativeBinaries\x86\*.*" "$(TargetDir)x86" -REM if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64" -REM xcopy /s /y "$(SolutionDir)packages\SqlServerCompact.4.0.8482.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64" - - - \ No newline at end of file diff --git a/Disco.Logging/LogBase.cs b/Disco.Logging/LogBase.cs deleted file mode 100644 index fa382519..00000000 --- a/Disco.Logging/LogBase.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Disco.Logging -{ - public abstract class LogBase - { - private Dictionary _EventTypes; - - public LogBase() - { - // Cache Event Types - _EventTypes = this.LoadEventTypes().ToDictionary(et => et.Id); - } - - public abstract int ModuleId { get; } - public abstract string ModuleName { get; } - public abstract string ModuleDescription { get; } - protected abstract List LoadEventTypes(); - - public Dictionary EventTypes - { - get - { - return _EventTypes; - } - } - protected void Log(int EventTypeId, params object[] Args) - { - LogContext.Current.Log(this.ModuleId, EventTypeId, Args); - } - public string LiveLogGroupName - { - get - { - return this.ModuleName; - } - } - - } -} diff --git a/Disco.Logging/LogContext.cs b/Disco.Logging/LogContext.cs deleted file mode 100644 index b0eb82aa..00000000 --- a/Disco.Logging/LogContext.cs +++ /dev/null @@ -1,311 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Data.Repository; -using System.IO; -using System.Management; -using System.Diagnostics; -using System.Data.SqlServerCe; -using System.Data.EntityClient; -using System.Data.Entity; -using Quartz; -using Quartz.Impl; -using Quartz.Impl.Triggers; - -namespace Disco.Logging -{ - public class LogContext - { - public static Dictionary LogModules { get; private set; } - private static object _LogModulesLock = new object(); - - private static LogContext _Current; - private static object _CurrentLock = new Object(); - public static LogContext Current - { - get - { - lock (_CurrentLock) - { - if (_Current == null) - throw new InvalidOperationException("Logging Context has not been Initialized"); - return _Current; - } - } - private set - { - lock (_CurrentLock) - { - _Current = value; - } - } - } - - private static void InitalizeModules() - { - if (LogModules == null) - { - lock (_LogModulesLock) - { - if (LogModules == null) - { - LogModules = new Dictionary(); - // Load all LogModules (Only from Disco Assemblies) - var appDomain = AppDomain.CurrentDomain; - - var logModuleTypes = (from a in appDomain.GetAssemblies() - where !a.GlobalAssemblyCache && !a.IsDynamic && a.FullName.StartsWith("Disco.", StringComparison.InvariantCultureIgnoreCase) - from type in a.GetTypes() - where typeof(LogBase).IsAssignableFrom(type) && !type.IsAbstract - select type); - foreach (var logModuleType in logModuleTypes) - { - var instance = (LogBase)Activator.CreateInstance(logModuleType); - LogModules[instance.ModuleId] = instance; - } - } - } - } - } - - private static void InitalizeDatabase(Targets.LogPersistContext logDbContext) - { - // Add Modules - var existingModules = logDbContext.Modules.Include("EventTypes").ToDictionary(m => m.Id); - foreach (var module in LogModules) - { - // Update/Insert Module - Models.LogModule dbModule; - if (existingModules.TryGetValue(module.Key, out dbModule)) - { - // Update - if (dbModule.Name != module.Value.ModuleName) - dbModule.Name = module.Value.ModuleName; - if (dbModule.Description != module.Value.ModuleDescription) - dbModule.Description = module.Value.ModuleDescription; - } - else - { - // Insert - dbModule = new Models.LogModule() - { - Id = module.Key, - Name = module.Value.ModuleName, - Description = module.Value.ModuleDescription - }; - logDbContext.Modules.Add(dbModule); - } - // Update/Insert Event Types - Dictionary existingEventTypes = (dbModule.EventTypes == null) ? new Dictionary() : dbModule.EventTypes.ToDictionary(et => et.Id); - foreach (var eventType in module.Value.EventTypes) - { - Models.LogEventType dbEventType; - if (existingEventTypes.TryGetValue(eventType.Key, out dbEventType)) - { - // Update - if (dbEventType.Name != eventType.Value.Name) - dbEventType.Name = eventType.Value.Name; - if (dbEventType.Severity != eventType.Value.Severity) - dbEventType.Severity = eventType.Value.Severity; - if (dbEventType.Format != eventType.Value.Format) - dbEventType.Format = eventType.Value.Format; - } - else - { - // Insert - dbEventType = new Models.LogEventType() - { - Id = eventType.Key, - ModuleId = module.Key, - Name = eventType.Value.Name, - Severity = eventType.Value.Severity, - Format = eventType.Value.Format - }; - logDbContext.EventTypes.Add(dbEventType); - } - } - } - - logDbContext.SaveChanges(); - } - - public static string LogFileBasePath(DiscoDataContext DiscoContext) - { - var logDirectoryBase = Path.Combine(DiscoContext.DiscoConfiguration.DataStoreLocation, "Logs"); - // Create Directory Structure - if (!Directory.Exists(logDirectoryBase)) - { - Directory.CreateDirectory(logDirectoryBase); - } - // Ensure Logs are NTFS Compressed - TODO... - //Utilities.CompressDirectory(logDirectory); - // WMI - Doesn't Work for Network Folders... - //var logDirectoryBaseInfo = new DirectoryInfo(logDirectoryBase); - //if ((logDirectoryBaseInfo.Attributes & FileAttributes.Compressed) != FileAttributes.Compressed) - //{ - // var logDirectoryWmiPath = string.Format("Win32_Directory.Name=\"{0}\"", logDirectoryBase); - // using (ManagementObject logDirectoryBaseMO = new ManagementObject(logDirectoryWmiPath)) - // { - // ManagementBaseObject outParams = logDirectoryBaseMO.InvokeMethod("Compress", null, null); - // Debug.WriteLine("LoggingContext.InitalizeCurrent: Compressing Log Folder; Result: " + outParams.Properties["ReturnValue"].Value.ToString()); - // } - //} - return logDirectoryBase; - } - - public static string LogFilePath(DiscoDataContext DiscoContext, DateTime Date, bool CreateDirectory = true) - { - var logDirectoryBase = LogFileBasePath(DiscoContext); - var logDirectory = Path.Combine(logDirectoryBase, Date.Year.ToString()); - if (CreateDirectory && !Directory.Exists(logDirectory)) - { - Directory.CreateDirectory(logDirectory); - } - var logFileName = string.Format("DiscoLog_{0:yyy-MM-dd}.sdf", Date); - return Path.Combine(logDirectory, logFileName); - } - - internal static void ReInitalize(DiscoDataContext DiscoContext) - { - lock (_CurrentLock) - { - var logPath = LogFilePath(DiscoContext, DateTime.Today); - - //var connectionString = string.Format("Data Source=\"{0}\"", logPath); - - SqlCeConnectionStringBuilder sqlCeCSB = new SqlCeConnectionStringBuilder(); - sqlCeCSB.DataSource = logPath; - var connectionString = sqlCeCSB.ToString(); - - // Ensure Database Exists - if (!File.Exists(logPath)) - { - // Create Database - using (var context = new Targets.LogPersistContext(connectionString)) - { - context.Database.CreateIfNotExists(); - } - } - - // Add Modules/Event Types - InitalizeModules(); - using (var context = new Targets.LogPersistContext(connectionString)) - { - InitalizeDatabase(context); - } - - // Create Current LogContext - var currentLogContext = new LogContext(logPath, connectionString); - _Current = currentLogContext; - } - SystemLog.LogLogInitialized(_Current.PersistantStorePath); - try - { - // Get Yesterdays Log - var yesterdaysLogPath = LogFilePath(DiscoContext, DateTime.Today.AddDays(-1), false); - if (File.Exists(yesterdaysLogPath)) - { - SqlCeConnectionStringBuilder sqlCeCSB = new SqlCeConnectionStringBuilder(); - sqlCeCSB.DataSource = yesterdaysLogPath; - var connectionString = sqlCeCSB.ToString(); - int logCount; - using (var context = new Targets.LogPersistContext(connectionString)) - { - logCount = context.Events.Where(e => !(e.ModuleId == 0 && e.EventTypeId == 100)).Count(); - if (logCount == 0) - { - // Delete (empty) Database - context.Database.Delete(); - } - } - } - } - catch (Exception ex) - { - SystemLog.LogError("Error occurred while investigating yesterdays log for deletion", ex.GetType().Name, ex.Message, ex.StackTrace); - } - } - - private static IScheduler _ReInitializeScheduler; - public static void Initalize(DiscoDataContext DiscoContext, ISchedulerFactory SchedulerFactory) - { - ReInitalize(DiscoContext); - - _ReInitializeScheduler = SchedulerFactory.GetScheduler(); - - var reInitalizeJobDetail = new JobDetailImpl("DiscoLogContextReinialize", typeof(LogReInitalizeJob)); - - // Simple Trigger - Issue with Day light savings - //var reInitalizeTrigger = TriggerBuilder.Create() - // .WithIdentity("DiscoLogContextReinializeTrigger") - // .StartAt(DateBuilder.TomorrowAt(0,0,0)) - // .WithSchedule(SimpleScheduleBuilder.Create().WithIntervalInHours(24).RepeatForever()) - // .Build(); - // Use Cron Schedule instead - var reInitalizeTrigger = TriggerBuilder.Create() - .WithIdentity("DiscoLogContextReinializeTrigger") - .StartNow() - .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 0)) // Midnight - .Build(); - - _ReInitializeScheduler.ScheduleJob(reInitalizeJobDetail, reInitalizeTrigger); - } - public static string LiveLogAllEventsGroupName - { - get - { - return Targets.LogLiveContext.LiveLogNameAll; - } - } - - private LogContext(string PersistantStorePath, string PersistantStoreConnectionString) - { - this.PersistantStorePath = PersistantStorePath; - this.PersistantStoreConnectionString = PersistantStoreConnectionString; - } - - public string PersistantStorePath { get; private set; } - public string PersistantStoreConnectionString { get; private set; } - - public void Log(int ModuleId, int EventTypeId, params object[] Args) - { - LogBase logModule; - if (LogModules.TryGetValue(ModuleId, out logModule)) - { - Models.LogEventType eventType; - if (logModule.EventTypes.TryGetValue(EventTypeId, out eventType)) - { - var eventTimestamp = DateTime.Now; - if (eventType.UseLive) - { - Targets.LogLiveContext.Broadcast(logModule, eventType, eventTimestamp, Args); - } - if (eventType.UsePersist) - { - string args = null; - if (Args != null && Args.Length > 0) - args = fastJSON.JSON.Instance.ToJSON(Args, false); - using (var context = new Targets.LogPersistContext(PersistantStoreConnectionString)) - { - var e = new Models.LogEvent() - { - Timestamp = eventTimestamp, - ModuleId = logModule.ModuleId, - EventTypeId = eventType.Id, - Arguments = args - }; - context.Events.Add(e); - context.SaveChanges(); - } - } - } - else - throw new InvalidOperationException(string.Format("Unknown Log Event Type Called: {0} (for Module: {1})", EventTypeId, ModuleId)); - } - else - throw new InvalidOperationException(string.Format("Unknown Log Module Called: {0}", ModuleId)); - } - - } -} diff --git a/Disco.Logging/LogReInitalizeJob.cs b/Disco.Logging/LogReInitalizeJob.cs deleted file mode 100644 index 04767a95..00000000 --- a/Disco.Logging/LogReInitalizeJob.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Quartz; -using Disco.Data.Repository; - -namespace Disco.Logging -{ - class LogReInitalizeJob : IJob - { - public void Execute(IJobExecutionContext context) - { - using (DiscoDataContext DiscoContext = new DiscoDataContext()) - { - LogContext.ReInitalize(DiscoContext); - } - } - } -} diff --git a/Disco.Logging/Models/LogEvent.cs b/Disco.Logging/Models/LogEvent.cs deleted file mode 100644 index bad62688..00000000 --- a/Disco.Logging/Models/LogEvent.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.ComponentModel.DataAnnotations; - -namespace Disco.Logging.Models -{ - [Table("Events")] - public class LogEvent - { - [Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } - [Required] - public int ModuleId { get; set; } - [Required] - public int EventTypeId { get; set; } - [Required] - public DateTime Timestamp { get; set; } - public string Arguments { get; set; } - } -} diff --git a/Disco.Logging/Models/LogEventType.cs b/Disco.Logging/Models/LogEventType.cs deleted file mode 100644 index 89ac5bdf..00000000 --- a/Disco.Logging/Models/LogEventType.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.ComponentModel.DataAnnotations; - -namespace Disco.Logging.Models -{ - [Table("EventTypes")] - public class LogEventType - { - [Required, Key, Column(Order=0), DatabaseGenerated(DatabaseGeneratedOption.None)] - public int ModuleId { get; set; } - [Required, Key, Column(Order = 1), DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id { get; set; } - [Required, MaxLength(200)] - public string Name { get; set; } - [Required] - public int Severity { get; set; } - [MaxLength(1024)] - public string Format { get; set; } - - [NotMapped] - public bool UsePersist { get; set; } - [NotMapped] - public bool UseLive { get; set; } - [NotMapped] - public bool UseDisplay { get; set; } - - [ForeignKey("ModuleId")] - public LogModule Module { get; set; } - - public enum Severities - { - Information = 0, - Warning = 1, - Error = 2 - } - - public string FormatMessage(object[] Arguments) - { - - if (Arguments != null && Arguments.Length > 0) - { - if (!string.IsNullOrEmpty(Format)) - { - return string.Format(Format, Arguments); - } - else - { - return Arguments - .Select(v => v == null ? string.Empty : v.ToString()) - .Aggregate((a, b) => a + ", " + (b == null ? string.Empty : b)); - } - } - else - { - if (!string.IsNullOrEmpty(Format)) - { - return Format; - } - } - return string.Empty; - } - } -} diff --git a/Disco.Logging/Models/LogLiveEvent.cs b/Disco.Logging/Models/LogLiveEvent.cs deleted file mode 100644 index 22bdcbf0..00000000 --- a/Disco.Logging/Models/LogLiveEvent.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Collections; - -namespace Disco.Logging.Models -{ - public class LogLiveEvent - { - public int ModuleId { get; set; } - public string ModuleName { get; set; } - public string ModuleDescription { get; set; } - public int EventTypeId { get; set; } - public string EventTypeName { get; set; } - public int EventTypeSeverity { get; set; } - - public DateTime Timestamp { get; set; } - public object[] Arguments { get; set; } - public string FormattedMessage { get; set; } - public string FormattedTimestamp { get; set; } - public bool UseDisplay { get; set; } - - public static LogLiveEvent Create(LogBase logModule, Models.LogEventType eventType, DateTime Timestamp, string jsonArguments) - { - object[] Arguments = null; - if (jsonArguments != null) - { - var alArguments = fastJSON.JSON.Instance.Parse(jsonArguments) as ArrayList; - if (alArguments != null) - { - Arguments = alArguments.ToArray(); - } - } - return Create(logModule, eventType, Timestamp, Arguments); - } - - public static LogLiveEvent Create(LogBase logModule, Models.LogEventType eventType, DateTime Timestamp, params object[] Arguments) - { - return new Models.LogLiveEvent() - { - ModuleId = logModule.ModuleId, - ModuleName = logModule.ModuleName, - ModuleDescription = logModule.ModuleDescription, - EventTypeId = eventType.Id, - EventTypeName = eventType.Name, - EventTypeSeverity = eventType.Severity, - Timestamp = Timestamp, - Arguments = Arguments, - FormattedMessage = eventType.FormatMessage(Arguments), - FormattedTimestamp = Timestamp.ToString("dd/MM/yyy hh:mm:ss tt"), - UseDisplay = eventType.UseDisplay - }; - } - - } -} diff --git a/Disco.Logging/Models/LogModule.cs b/Disco.Logging/Models/LogModule.cs deleted file mode 100644 index ffc8dd41..00000000 --- a/Disco.Logging/Models/LogModule.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.ComponentModel.DataAnnotations; - -namespace Disco.Logging.Models -{ - [Table("Modules")] - public class LogModule - { - [Required, Key, DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id { get; set; } - [Required, MaxLength(200)] - public string Name { get; set; } - [Required, MaxLength(500)] - public string Description { get; set; } - - public virtual IList EventTypes { get; set; } - } -} diff --git a/Disco.Logging/Properties/AssemblyInfo.cs b/Disco.Logging/Properties/AssemblyInfo.cs deleted file mode 100644 index 21404bbc..00000000 --- a/Disco.Logging/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Disco - Logging")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Disco")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("03a4a5bf-60c6-4dff-b623-387043b8be86")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2012.0627.1427")] -[assembly: AssemblyFileVersion("1.2012.0627.1427")] diff --git a/Disco.Logging/ReadLogContext.cs b/Disco.Logging/ReadLogContext.cs deleted file mode 100644 index 81f0a306..00000000 --- a/Disco.Logging/ReadLogContext.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Logging.Targets; -using Disco.Data.Repository; -using System.IO; -using System.Text.RegularExpressions; -using System.Data.SqlServerCe; -using Disco.Logging.Models; - -namespace Disco.Logging -{ - public class ReadLogContext - { - public DateTime? Start { get; set; } - public DateTime? End { get; set; } - public int? Take { get; set; } - public int? Module { get; set; } - public List EventTypes { get; set; } - - public bool Validate() - { - if (this.Start.HasValue && this.End.HasValue && this.End.Value < this.Start.Value) - throw new ArgumentOutOfRangeException("End", "End must be greater than Start"); - if (this.Start.HasValue && !this.End.HasValue && this.Start > DateTime.Now) - throw new ArgumentOutOfRangeException("Start", "Start must be less than current time"); - - return true; - } - - public List Query(DiscoDataContext DiscoContext) - { - List results = new List(); - - // Validate Options - this.Validate(); - - var relevantLogFiles = RelevantLogFiles(DiscoContext); - relevantLogFiles.Reverse(); - foreach (var logFile in relevantLogFiles) - { - SqlCeConnectionStringBuilder sqlCeCSB = new SqlCeConnectionStringBuilder(); - sqlCeCSB.DataSource = logFile.Item1; - - var logModules = LogContext.LogModules; - - using (var context = new Targets.LogPersistContext(sqlCeCSB.ToString())) - { - var query = this.BuildQuery(context, logFile.Item2, results.Count); - IEnumerable queryResults = query; // Run the Query - results.AddRange(queryResults.Select(le => Models.LogLiveEvent.Create(logModules[le.ModuleId], logModules[le.ModuleId].EventTypes[le.EventTypeId], le.Timestamp, le.Arguments))); - } - if (this.Take.HasValue && this.Take.Value < results.Count) - break; - } - return results; - } - - private static Regex LogFileDateRegex = new Regex("DiscoLog_([0-9]{4})-([0-9]{2})-([0-9]{2}).sdf", RegexOptions.IgnoreCase); - private static DateTime? LogFileDate(string LogFilePath) - { - var fileNameMatch = LogFileDateRegex.Match(LogFilePath); - if (fileNameMatch.Success) - { - return new DateTime(int.Parse(fileNameMatch.Groups[1].Value), - int.Parse(fileNameMatch.Groups[2].Value), - int.Parse(fileNameMatch.Groups[3].Value)); - } - else - { - return null; - } - } - - private List> RelevantLogFiles(DiscoDataContext DiscoContext) - { - List> relevantFiles = new List>(); - var logDirectoryBase = LogContext.LogFileBasePath(DiscoContext); - var logDirectoryBaseInfo = new DirectoryInfo(logDirectoryBase); - var endDate = this.End.HasValue ? this.End.Value : DateTime.Now; - var endDateYear = endDate.Year.ToString(); - - // Try Shortcut ( < 31 Days in Query) - if (this.Start.HasValue) - { - if ((this.End.HasValue && this.End.Value.Subtract(this.Start.Value).Days < 31) || - (!this.End.HasValue && DateTime.Now.Subtract(this.Start.Value).Days < 31)) - { - // Less than 31 Days in Query - Just evaluate each Path - var queryDate = this.Start.Value.Date; - while (queryDate <= endDate) - { - var fileName = LogContext.LogFilePath(DiscoContext, queryDate, false); - if (File.Exists(fileName)) - relevantFiles.Add(new Tuple(fileName, LogFileDate(fileName).Value)); - - queryDate = queryDate.AddDays(1); - } - return relevantFiles; - } - } - - List logYears = new List(); - foreach (var directoryName in logDirectoryBaseInfo.GetDirectories()) - { - int directoryYear; - if (int.TryParse(directoryName.Name, out directoryYear)) - { - logYears.Add(directoryName.Name); - } - } - logYears.Sort(); - - foreach (var logYear in logYears) - { - List logFiles = Directory.EnumerateFiles(Path.Combine(logDirectoryBase, logYear), "DiscoLog_*.sdf").ToList(); - logFiles.Sort(); - if (logYear != endDateYear) - { - foreach (var logFile in logFiles) - { - relevantFiles.Add(new Tuple(logFile, LogFileDate(logFile).Value)); - } - } - else - { - foreach (var logFile in logFiles) - { - var fileNameDate = LogFileDate(logFile); - if (fileNameDate != null) - { - if (fileNameDate.Value < endDate) - { - relevantFiles.Add(new Tuple(logFile, fileNameDate.Value)); - } - else - { - break; // Files are sorted, must be no more... - } - } - } - break; // Years are sorted, must be no more... - } - } - return relevantFiles; - } - - private IQueryable BuildQuery(LogPersistContext LogContext, DateTime LogDate, int Taken) - { - IQueryable query = LogContext.Events.OrderByDescending(le => le.Timestamp); - if (this.Module.HasValue) - { - query = query.Where(le => le.ModuleId == this.Module.Value); - } - if (this.EventTypes != null && this.EventTypes.Count > 0) - { - query = query.Where(le => this.EventTypes.Contains(le.EventTypeId)); - } - if (this.Start.HasValue && this.Start.Value > LogDate) - { - var startValue = DateTime.SpecifyKind(this.Start.Value, DateTimeKind.Local); - query = query.Where(le => le.Timestamp > startValue); - } - if (this.End.HasValue && this.End.Value <= LogDate.AddDays(1)) - { - var endValue = DateTime.SpecifyKind(this.End.Value, DateTimeKind.Local); - query = query.Where(le => le.Timestamp < endValue); - } - if (this.Take.HasValue && this.Take.Value > 0) - { - var take = this.Take.Value - Taken; - query = query.Take(take); - } - return query; - } - - } -} diff --git a/Disco.Logging/SystemLog.cs b/Disco.Logging/SystemLog.cs deleted file mode 100644 index 5b8ddff8..00000000 --- a/Disco.Logging/SystemLog.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Logging.Models; - -namespace Disco.Logging -{ - public class SystemLog : LogBase - { - private const int _ModuleId = 0; - public enum EventTypeIds : int - { - Information = 0, - Warning = 1, - Error = 2, - Exception = 10, - ExceptionWithInner = 11, - LogInitialized = 100 - } - public static SystemLog Current - { - get - { - return (SystemLog)LogContext.LogModules[_ModuleId]; - } - } - private static void Log(EventTypeIds EventTypeId, params object[] Args) - { - Current.Log((int)EventTypeId, Args); - } - public static void LogInformation(params object[] Messages) - { - Log(EventTypeIds.Information, Messages); - } - public static void LogWarning(params object[] Messages) - { - Log(EventTypeIds.Warning, Messages); - } - public static void LogError(params object[] Messages) - { - Log(EventTypeIds.Error, Messages); - } - public static void LogException(string Component, Exception ex) - { - if (ex.InnerException != null) - { - Log(EventTypeIds.ExceptionWithInner, Component, ex.GetType().Name, ex.Message, ex.StackTrace, ex.InnerException.GetType().Name, ex.InnerException.Message, ex.InnerException.StackTrace); - } - else - { - Log(EventTypeIds.Exception, Component, ex.GetType().Name, ex.Message, ex.StackTrace); - } - } - - public static void LogLogInitialized(string PersistantStorePath) - { - Log(EventTypeIds.LogInitialized, PersistantStorePath); - } - - public override int ModuleId - { - get { return _ModuleId; } - } - - public override string ModuleName - { - get { return "System"; } - } - - public override string ModuleDescription - { - get { return "Core System Log"; } - } - - protected override List LoadEventTypes() - { - List eventTypes = new List() { - new LogEventType() { - Id = (int)EventTypeIds.Information, - ModuleId = _ModuleId, - Name = "Information", - Format = null, - Severity = (int)LogEventType.Severities.Information, - UseLive = true, UsePersist = true, UseDisplay = true }, - new LogEventType() { - Id = (int)EventTypeIds.Warning, - ModuleId = _ModuleId, - Name = "Warning", - Format = null, - Severity = (int)LogEventType.Severities.Warning, - UseLive = true, UsePersist = true, UseDisplay = true }, - new LogEventType() { - Id = (int)EventTypeIds.Error, - ModuleId = _ModuleId, - Name = "Error", - Format = null, - Severity = (int)LogEventType.Severities.Error, - UseLive = true, UsePersist = true, UseDisplay = true }, - new LogEventType() { - Id = (int)EventTypeIds.Exception, - ModuleId = _ModuleId, - Name = "Exception", - Format = "{0}; {1}: {2}; {3}", - Severity = (int)LogEventType.Severities.Error, - UseLive = true, UsePersist = true, UseDisplay = true }, - new LogEventType() { - Id = (int)EventTypeIds.ExceptionWithInner, - ModuleId = _ModuleId, - Name = "Exception with Inner Exception", - Format = "{0}; {1}: {2}; {3}; {4}: {5}; {6}", - Severity = (int)LogEventType.Severities.Error, - UseLive = true, UsePersist = true, UseDisplay = true }, - new LogEventType() { - Id = (int)EventTypeIds.LogInitialized, - ModuleId = _ModuleId, - Name = "Log Initialized", - Format = "Log Initialized to '{0}'", - Severity = (int)LogEventType.Severities.Information, - UseLive = false, UsePersist = true, UseDisplay = true } - }; - - return eventTypes; - } - } -} diff --git a/Disco.Logging/Targets/LogLiveContext.cs b/Disco.Logging/Targets/LogLiveContext.cs deleted file mode 100644 index 3e04983c..00000000 --- a/Disco.Logging/Targets/LogLiveContext.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using SignalR; -using SignalR.Hosting.AspNet; -using SignalR.Infrastructure; - -namespace Disco.Logging.Targets -{ - public class LogLiveContext : PersistentConnection - { - protected override System.Threading.Tasks.Task OnReceivedAsync(string connectionId, string data) - { - // Add to Group - if (!string.IsNullOrWhiteSpace(data) && data.StartsWith("/addToGroups:") && data.Length > 13) - { - var groups = data.Substring(13).Split(','); - foreach (var g in groups) - { - this.AddToGroup(connectionId, g); - } - } - - return base.OnReceivedAsync(connectionId, data); - } - - internal static void Broadcast(LogBase logModule, Models.LogEventType eventType, DateTime Timestamp, params object[] Arguments) - { - var message = Models.LogLiveEvent.Create(logModule, eventType, Timestamp, Arguments); - - var connectionManager = AspNetHost.DependencyResolver.Resolve(); - var connection = connectionManager.GetConnection(); - connection.Broadcast(_QualifiedTypeNameAll, message); - connection.Broadcast(LiveLogNameGroup(logModule.ModuleName), message); - } - - private const string _GroupNameAll = "__All"; - private static string _QualifiedTypeName = typeof(LogLiveContext).FullName + "."; - private static string _QualifiedTypeNameAll = _QualifiedTypeName + "__All"; - private static string LiveLogNameGroup(string LogName) - { - return string.Concat(_QualifiedTypeName, LogName); - } - public static string LiveLogNameAll - { - get - { - //return _QualifiedTypeNameAll; - return _GroupNameAll; - } - } - - } -} diff --git a/Disco.Logging/Targets/LogPersistContext.cs b/Disco.Logging/Targets/LogPersistContext.cs deleted file mode 100644 index f2a31f8a..00000000 --- a/Disco.Logging/Targets/LogPersistContext.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; - -namespace Disco.Logging.Targets -{ - public class LogPersistContext : DbContext - { - public LogPersistContext(string ConnectionString) : base(ConnectionString) { } - - public DbSet Modules { get; set; } - public DbSet EventTypes { get; set; } - public DbSet Events { get; set; } - - protected override void OnModelCreating(DbModelBuilder modelBuilder) - { - //modelBuilder.Conventions.Remove(); - } - } -} diff --git a/Disco.Logging/Utilities.cs b/Disco.Logging/Utilities.cs deleted file mode 100644 index 9600ecec..00000000 --- a/Disco.Logging/Utilities.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Win32.SafeHandles; -using System.Runtime.InteropServices; -using System.IO; -using System.Web.Mvc; - -namespace Disco.Logging -{ - public static class Utilities - { - - public const string LogEventCSVHeader = "Timestamp,ModuleId,ModuleName,ModuleDescription,EventTypeId,EventTypeName,Severity,Message"; - public static void ToCsvLine(this Models.LogLiveEvent e, TextWriter writer) - { - writer.Write(e.Timestamp.ToString("yyy-MM-dd HH:mm:ss")); - writer.Write(","); - writer.Write(e.ModuleId); - writer.Write(",\""); - writer.Write(e.ModuleName); - writer.Write("\",\""); - writer.Write(e.ModuleDescription); - writer.Write("\","); - writer.Write(e.EventTypeId); - writer.Write(",\""); - writer.Write(e.EventTypeName); - writer.Write("\","); - writer.Write(e.EventTypeSeverity); - writer.Write(",\""); - writer.Write(e.FormattedMessage.Replace("\"", "'")); - writer.Write("\""); - if (e.Arguments != null) - { - foreach (var arg in e.Arguments) - { - writer.Write(",\""); - writer.Write(arg.ToString().Replace("\"", "'")); - writer.Write("\""); - } - } - writer.WriteLine(); - } - public static MemoryStream ToCsv(this List e) - { - var ms = new MemoryStream(); - StreamWriter sw = new StreamWriter(ms); - sw.WriteLine(LogEventCSVHeader); - if (e != null) - { - foreach (var le in e) - { - le.ToCsvLine(sw); - } - } - sw.Flush(); - ms.Position = 0; - return ms; - } - - public static List ToSelectListItems(this List items) - { - return items.Select(et => new SelectListItem() { Value = et.Id.ToString(), Text = et.Name }).ToList(); - } - - #region Win32 APIs - /// - /// The CreateFile function creates or opens a file, file stream, directory, physical disk, volume, console buffer, tape drive, - /// communications resource, mailslot, or named pipe. The function returns a handle that can be used to access an object. - /// - /// - /// access to the object, which can be read, write, or both - /// The sharing mode of an object, which can be read, write, both, or none - /// A pointer to a SECURITY_ATTRIBUTES structure that determines whether or not the returned handle can - /// be inherited by child processes. Can be null - /// An action to take on files that exist and do not exist - /// The file attributes and flags. - /// A handle to a template file with the GENERIC_READ access right. The template file supplies file attributes - /// and extended attributes for the file that is being created. This parameter can be null - /// If the function succeeds, the return value is an open handle to a specified file. If a specified file exists before the function - /// all and dwCreationDisposition is CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS, even when the function - /// succeeds. If a file does not exist before the call, GetLastError returns 0 (zero). - /// If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError. - /// - [DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)] - private static extern SafeFileHandle CreateFile( - string lpFileName, - EFileAccess dwDesiredAccess, - EFileShare dwShareMode, - IntPtr SecurityAttributes, - ECreationDisposition dwCreationDisposition, - EFileAttributes dwFlagsAndAttributes, - IntPtr hTemplateFile - ); - [Flags] - private enum EFileAccess : uint - { - Delete = 0x10000, - ReadControl = 0x20000, - WriteDAC = 0x40000, - WriteOwner = 0x80000, - Synchronize = 0x100000, - - StandardRightsRequired = 0xF0000, - StandardRightsRead = ReadControl, - StandardRightsWrite = ReadControl, - StandardRightsExecute = ReadControl, - StandardRightsAll = 0x1F0000, - SpecificRightsAll = 0xFFFF, - - AccessSystemSecurity = 0x1000000, // AccessSystemAcl access type - - MaximumAllowed = 0x2000000, // MaximumAllowed access type - - GenericRead = 0x80000000, - GenericWrite = 0x40000000, - GenericExecute = 0x20000000, - GenericAll = 0x10000000 - } - [Flags] - private enum EFileShare : uint - { - /// - /// - /// - None = 0x00000000, - /// - /// Enables subsequent open operations on an object to request read access. - /// Otherwise, other processes cannot open the object if they request read access. - /// If this flag is not specified, but the object has been opened for read access, the function fails. - /// - Read = 0x00000001, - /// - /// Enables subsequent open operations on an object to request write access. - /// Otherwise, other processes cannot open the object if they request write access. - /// If this flag is not specified, but the object has been opened for write access, the function fails. - /// - Write = 0x00000002, - /// - /// Enables subsequent open operations on an object to request delete access. - /// Otherwise, other processes cannot open the object if they request delete access. - /// If this flag is not specified, but the object has been opened for delete access, the function fails. - /// - Delete = 0x00000004 - } - private enum ECreationDisposition : uint - { - /// - /// Creates a new file. The function fails if a specified file exists. - /// - New = 1, - /// - /// Creates a new file, always. - /// If a file exists, the function overwrites the file, clears the existing attributes, combines the specified file attributes, - /// and flags with FILE_ATTRIBUTE_ARCHIVE, but does not set the security descriptor that the SECURITY_ATTRIBUTES structure specifies. - /// - CreateAlways = 2, - /// - /// Opens a file. The function fails if the file does not exist. - /// - OpenExisting = 3, - /// - /// Opens a file, always. - /// If a file does not exist, the function creates a file as if dwCreationDisposition is CREATE_NEW. - /// - OpenAlways = 4, - /// - /// Opens a file and truncates it so that its size is 0 (zero) bytes. The function fails if the file does not exist. - /// The calling process must open the file with the GENERIC_WRITE access right. - /// - TruncateExisting = 5 - } - [Flags] - private enum EFileAttributes : uint - { - None = 0x0000000, - Readonly = 0x00000001, - Hidden = 0x00000002, - System = 0x00000004, - Directory = 0x00000010, - Archive = 0x00000020, - Device = 0x00000040, - Normal = 0x00000080, - Temporary = 0x00000100, - SparseFile = 0x00000200, - ReparsePoint = 0x00000400, - Compressed = 0x00000800, - Offline = 0x00001000, - NotContentIndexed = 0x00002000, - Encrypted = 0x00004000, - Write_Through = 0x80000000, - Overlapped = 0x40000000, - NoBuffering = 0x20000000, - RandomAccess = 0x10000000, - SequentialScan = 0x08000000, - DeleteOnClose = 0x04000000, - BackupSemantics = 0x02000000, - PosixSemantics = 0x01000000, - OpenReparsePoint = 0x00200000, - OpenNoRecall = 0x00100000, - FirstPipeInstance = 0x00080000 - } - - private const int FSCTL_SET_COMPRESSION = 0x9C040; - private const short COMPRESSION_FORMAT_DEFAULT = 1; - [DllImport("kernel32.dll", SetLastError = true)] - private static extern int DeviceIoControl( - SafeFileHandle hDevice, - int dwIoControlCode, - ref short lpInBuffer, - int nInBufferSize, - IntPtr lpOutBuffer, - int nOutBufferSize, - ref int lpBytesReturned, - IntPtr lpOverlapped); - #endregion - - public static void CompressDirectory(string DirectoryPath) - { - if (DirectoryPath.Length > 250) - throw new InvalidOperationException(string.Format("Directory Path to Long (>250) to Compress: {0}", DirectoryPath)); - - DirectoryInfo dirInfo = new DirectoryInfo(DirectoryPath); - if (dirInfo.Exists) - { - if ((dirInfo.Attributes & FileAttributes.Compressed) != FileAttributes.Compressed) - { - var dirHandle = CreateFile(DirectoryPath, EFileAccess.GenericWrite, EFileShare.Read, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.None, IntPtr.Zero); - if (dirHandle.IsInvalid) - { - Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); - } - else - { - EnableCompression(dirHandle); - dirHandle.Close(); - } - } - } - else - { - throw new InvalidOperationException(string.Format("Directory doesn't exist: {0}", DirectoryPath)); - } - } - - private static void EnableCompression(SafeFileHandle handle) - { - int lpBytesReturned = 0; - short lpInBuffer = COMPRESSION_FORMAT_DEFAULT; - - int result = DeviceIoControl(handle, FSCTL_SET_COMPRESSION, - ref lpInBuffer, sizeof(short), IntPtr.Zero, 0, - ref lpBytesReturned, IntPtr.Zero); - - if (result != 0) - { - Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error()); - } - } - - } -} diff --git a/Disco.Logging/packages.config b/Disco.Logging/packages.config deleted file mode 100644 index 065b8424..00000000 --- a/Disco.Logging/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Disco.Silverlight.AttachmentUpload/App.xaml b/Disco.Silverlight.AttachmentUpload/App.xaml deleted file mode 100644 index 9ba4bcda..00000000 --- a/Disco.Silverlight.AttachmentUpload/App.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Disco.Silverlight.AttachmentUpload/App.xaml.vb b/Disco.Silverlight.AttachmentUpload/App.xaml.vb deleted file mode 100644 index 40bc5adb..00000000 --- a/Disco.Silverlight.AttachmentUpload/App.xaml.vb +++ /dev/null @@ -1,37 +0,0 @@ -Partial Public Class App - Inherits Application - - Public Shared Property UploadUrl As Uri - Public Shared Property MainPage As MainPage - - Public Sub New() - InitializeComponent() - End Sub - - Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup - MainPage = New MainPage - - Me.RootVisual = MainPage - - UploadUrl = New Uri(Application.Current.Host.Source.AbsoluteUri.Substring(0, Application.Current.Host.Source.AbsoluteUri.IndexOf("/", 8)) & e.InitParams.Item("UploadUrl")) - - End Sub - - Private Sub Application_UnhandledException(ByVal sender As Object, ByVal e As ApplicationUnhandledExceptionEventArgs) Handles Me.UnhandledException - - ' If the app is running outside of the debugger then report the exception using - ' the browser's exception mechanism. On IE this will display it a yellow alert - ' icon in the status bar and Firefox will display a script error. - If Not System.Diagnostics.Debugger.IsAttached Then - - ' NOTE: This will allow the application to continue running after an exception has been thrown - ' but not handled. - ' For production applications this error handling should be replaced with something that will - ' report the error to the website and stop the application. - e.Handled = True - Dim errorWindow As ChildWindow = New ErrorWindow(e.ExceptionObject) - errorWindow.Show() - End If - End Sub - -End Class diff --git a/Disco.Silverlight.AttachmentUpload/Assets/Styles.xaml b/Disco.Silverlight.AttachmentUpload/Assets/Styles.xaml deleted file mode 100644 index c2b803fe..00000000 --- a/Disco.Silverlight.AttachmentUpload/Assets/Styles.xaml +++ /dev/null @@ -1,350 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Disco.Silverlight.AttachmentUpload/Assets/dropTarget.png b/Disco.Silverlight.AttachmentUpload/Assets/dropTarget.png deleted file mode 100644 index 5f1eaf57..00000000 Binary files a/Disco.Silverlight.AttachmentUpload/Assets/dropTarget.png and /dev/null differ diff --git a/Disco.Silverlight.AttachmentUpload/Disco.Silverlight.AttachmentUpload.sln b/Disco.Silverlight.AttachmentUpload/Disco.Silverlight.AttachmentUpload.sln deleted file mode 100644 index a9e03ef8..00000000 --- a/Disco.Silverlight.AttachmentUpload/Disco.Silverlight.AttachmentUpload.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Disco.Silverlight.AttachmentUpload", "Disco.Silverlight.AttachmentUpload.vbproj", "{85747DDC-1389-4A40-9AFC-F57E0992294E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {85747DDC-1389-4A40-9AFC-F57E0992294E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {85747DDC-1389-4A40-9AFC-F57E0992294E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {85747DDC-1389-4A40-9AFC-F57E0992294E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {85747DDC-1389-4A40-9AFC-F57E0992294E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Disco.Silverlight.AttachmentUpload/Disco.Silverlight.AttachmentUpload.vbproj b/Disco.Silverlight.AttachmentUpload/Disco.Silverlight.AttachmentUpload.vbproj deleted file mode 100644 index b89a6544..00000000 --- a/Disco.Silverlight.AttachmentUpload/Disco.Silverlight.AttachmentUpload.vbproj +++ /dev/null @@ -1,194 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {85747DDC-1389-4A40-9AFC-F57E0992294E} - {A1591282-1198-4647-A2B1-27E5FF5F6F3B};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} - Library - Disco.Silverlight.AttachmentUpload - Disco.Silverlight.AttachmentUpload - Silverlight - v4.0 - $(TargetFrameworkVersion) - true - - - true - true - Disco.Silverlight.AttachmentUpload.xap - My Project\AppManifest.xml - Disco.Silverlight.AttachmentUpload.App - Disco.Silverlight.AttachmentUploadTestPage.html - true - true - false - My Project\OutOfBrowserSettings.xml - true - false - - - - - - v3.5 - - - true - full - true - true - true - true - Empty - Bin\Debug - Disco.Silverlight.AttachmentUpload.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - SILVERLIGHT=1 - - - pdbonly - false - true - true - true - true - Bin\Release - Disco.Silverlight.AttachmentUpload.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - SILVERLIGHT=1 - - - On - - - Binary - - - Off - - - On - - - - ..\..\Resources\Libraries\fastJSON\fastJSON-SL.dll - - - ..\..\Resources\Libraries\FJ.Core\FJ.Core.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - App.xaml - - - - - MainPage.xaml - - - - - FileWindow.xaml - - - ErrorWindow.xaml - - - File.xaml - - - Hidden.xaml - - - WebCam.xaml - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Disco.Silverlight.AttachmentUpload/FileUploader.vb b/Disco.Silverlight.AttachmentUpload/FileUploader.vb deleted file mode 100644 index 3693e52f..00000000 --- a/Disco.Silverlight.AttachmentUpload/FileUploader.vb +++ /dev/null @@ -1,77 +0,0 @@ -Imports System.Text -Imports Disco.Silverlight.AttachmentUpload.BI - -Public Class FileUploader - - Public Property Url As Uri - Public Property Stream As IO.Stream - Public Property StreamFilename As String - Public Property StreamMimeType As String - Public Property Form As Dictionary(Of String, String) - - Private _HttpSend As HttpWebRequest - Private _UploadBoundaryValue As String - - Private _Complete As UploadComplete - - Public Delegate Sub UploadComplete(Sender As FileUploader, Success As Boolean, Id As Integer) - - Public Sub New(Url As Uri, Stream As IO.Stream, StreamFilename As String, StreamMimeType As String, Form As Dictionary(Of String, String), Optional Complete As UploadComplete = Nothing) - Me.Url = Url - Me.Stream = Stream - Me.StreamFilename = StreamFilename - Me.StreamMimeType = StreamMimeType - Me.Form = Form - Me._Complete = Complete - - Start() - End Sub - - Public Sub Start() - Stream.Position = 0 - Me._HttpSend = WebRequest.Create(App.UploadUrl) - Me._UploadBoundaryValue = ("----------------------------" & DateTime.Now.Ticks.ToString("x")) - Me._HttpSend.ContentType = "multipart/form-data; boundary=" & Me._UploadBoundaryValue - Me._HttpSend.Method = "POST" - Me._HttpSend.BeginGetRequestStream(New AsyncCallback(AddressOf Me.BeginSendRequest), Nothing) - End Sub - - Private Sub BeginSendRequest(ByVal result As IAsyncResult) - Using requestStream As IO.Stream = _HttpSend.EndGetRequestStream(result) - Dim format As String = ("{0}--" & _UploadBoundaryValue & "{0}Content-Disposition: form-data; name=""{1}"";{0}{0}{2}") - Dim pair As KeyValuePair(Of String, String) - For Each pair In Form - Dim str4 As String = String.Format(format, Environment.NewLine, pair.Key, pair.Value) - Dim buffer3 As Byte() = Encoding.UTF8.GetBytes(str4) - requestStream.Write(buffer3, 0, buffer3.Length) - Next - Dim s As String = String.Format(("{0}--" & _UploadBoundaryValue & "{0}Content-Disposition: form-data; name=""{1}""; filename=""{2}""{0}Content-Type: {3}{0}{0}"), Environment.NewLine, "File", Me.StreamFilename, Me.StreamMimeType) - Dim bytes As Byte() = Encoding.UTF8.GetBytes(s) - requestStream.Write(bytes, 0, bytes.Length) - Me.Stream.CopyTo(requestStream) - Me.Stream.Close() - Me.Stream.Dispose() - Dim buffer As Byte() = Encoding.UTF8.GetBytes(String.Format("{0}--{1}{0}", Environment.NewLine, Me._UploadBoundaryValue)) - requestStream.Write(buffer, 0, buffer.Length) - requestStream.Flush() - requestStream.Close() - End Using - _HttpSend.BeginGetResponse(New AsyncCallback(AddressOf Me.BeginGetResponse), Nothing) - End Sub - - Private Sub BeginGetResponse(ByVal result As IAsyncResult) - Dim response As HttpWebResponse = _HttpSend.EndGetResponse(result) - - Dim responseId As Integer = -1 - - If response.StatusCode = 200 Then - Dim responseString = response.GetResponseStream.StreamToString() - Integer.TryParse(responseString, responseId) - End If - - If _Complete IsNot Nothing Then - _Complete.Invoke(Me, (response.StatusCode = 200), responseId) - End If - End Sub - -End Class diff --git a/Disco.Silverlight.AttachmentUpload/JavascriptNavigator.vb b/Disco.Silverlight.AttachmentUpload/JavascriptNavigator.vb deleted file mode 100644 index 82767946..00000000 --- a/Disco.Silverlight.AttachmentUpload/JavascriptNavigator.vb +++ /dev/null @@ -1,24 +0,0 @@ -Imports System.Windows.Browser - - -Public Class JavascriptNavigator - - Private _contentFrame As Controls.Frame - - Public Sub New(contentFrame As Controls.Frame) - _contentFrame = contentFrame - End Sub - - - Public Sub Navigate(uri As String) - _contentFrame.Navigate(New Uri(uri, UriKind.Relative)) - End Sub - - - Public ReadOnly Property Location As String - Get - Return _contentFrame.Source.ToString - End Get - End Property - -End Class diff --git a/Disco.Silverlight.AttachmentUpload/MainPage.xaml b/Disco.Silverlight.AttachmentUpload/MainPage.xaml deleted file mode 100644 index 416b0e84..00000000 --- a/Disco.Silverlight.AttachmentUpload/MainPage.xaml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Disco.Silverlight.AttachmentUpload/MainPage.xaml.vb b/Disco.Silverlight.AttachmentUpload/MainPage.xaml.vb deleted file mode 100644 index a54a03a3..00000000 --- a/Disco.Silverlight.AttachmentUpload/MainPage.xaml.vb +++ /dev/null @@ -1,60 +0,0 @@ -Imports System.Windows.Navigation -Imports System.Windows.Browser - -Partial Public Class MainPage - Inherits UserControl - - Private _Navigator As JavascriptNavigator - - Private _UploadingAttachments As New List(Of FileUploader) - - Public Sub New() - InitializeComponent() - - _Navigator = New JavascriptNavigator(Me.ContentFrame) - HtmlPage.RegisterScriptableObject("Navigator", _Navigator) - End Sub - - Private Sub ContentFrame_NavigationFailed(ByVal sender As Object, ByVal e As NavigationFailedEventArgs) Handles ContentFrame.NavigationFailed - e.Handled = True - Dim errorWindow As ChildWindow = New ErrorWindow(e.Uri) - errorWindow.Show() - End Sub - - Public Sub UploadAttachment(stream As IO.Stream, fileName As String, mimeType As String, comments As String) - - Dim form As New Dictionary(Of String, String) - form.Add("comments", comments) - - Dim ua As New FileUploader(App.UploadUrl, stream, fileName, mimeType, form, New FileUploader.UploadComplete(AddressOf UploadComplete)) - - _UploadingAttachments.Add(ua) - - 'Me.NavigationGrid.Visibility = Windows.Visibility.Visible - - End Sub - - Private Sub UploadComplete(Sender As FileUploader, Success As Boolean, Id As Integer) - If _UploadingAttachments.Contains(Sender) Then - _UploadingAttachments.Remove(Sender) - End If - - 'If _UploadingAttachments.Count = 0 Then - ' Me.Dispatcher.BeginInvoke(Function() - ' Me.NavigationGrid.Visibility = Windows.Visibility.Collapsed - ' Return Nothing - ' End Function) - 'End If - - If Id >= 0 Then - Me.Dispatcher.BeginInvoke(Function() - Dim discoFunctions = System.Windows.Browser.HtmlPage.Document.GetProperty("DiscoFunctions") - If discoFunctions IsNot Nothing Then - discoFunctions.addAttachment(Id) - End If - Return (Nothing) - End Function) - End If - End Sub - -End Class \ No newline at end of file diff --git a/Disco.Silverlight.AttachmentUpload/My Project/AppManifest.xml b/Disco.Silverlight.AttachmentUpload/My Project/AppManifest.xml deleted file mode 100644 index 1370dcae..00000000 --- a/Disco.Silverlight.AttachmentUpload/My Project/AppManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Disco.Silverlight.AttachmentUpload/My Project/AssemblyInfo.vb b/Disco.Silverlight.AttachmentUpload/My Project/AssemblyInfo.vb deleted file mode 100644 index 70e2dc4e..00000000 --- a/Disco.Silverlight.AttachmentUpload/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,34 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' General Information about an assembly is controlled through the following -' set of attributes. Change these attribute values to modify the information -' associated with an assembly. - -' Review the values of the assembly attributes - - - - - - - - - -'The following GUID is for the ID of the typelib if this project is exposed to COM - - -' Version information for an assembly consists of the following four values: -' -' Major Version -' Minor Version -' Build Number -' Revision -' -' You can specify all the values or you can default the Build and Revision Numbers -' by using the '*' as shown below: -' - - - diff --git a/Disco.Silverlight.AttachmentUpload/Utilities.vb b/Disco.Silverlight.AttachmentUpload/Utilities.vb deleted file mode 100644 index 3ce830a0..00000000 --- a/Disco.Silverlight.AttachmentUpload/Utilities.vb +++ /dev/null @@ -1,151 +0,0 @@ -Imports System.Runtime.CompilerServices -#If Not SILVERLIGHT = 1 Then -Imports System.Web.Mvc -#End If - -Namespace BI - - Public Module Utilities - - - Public Function StreamToString(stream As IO.Stream) As String - If (stream.Position <> 0) Then - stream.Position = 0 - End If - Using sr As IO.StreamReader = New IO.StreamReader(stream) - Return sr.ReadToEnd - End Using - End Function - - - Public Function ToFuzzy(d As DateTime) As String - - Dim n = DateTime.Now - '' Today - If d.Date = n.Date Then - '' Earlier - If d < n Then - '' Earlier - If d > n.AddMinutes(-1) Then - Return String.Format("A moment ago") - End If - - If d > n.AddMinutes(-10) Then - Return String.Format("A few minutes ago") - End If - Else - '' Later - If d < n.AddMinutes(1) Then - Return String.Format("In a moment") - End If - - If d < n.AddMinutes(10) Then - Return String.Format("In a few minutes") - End If - End If - - Return String.Format("Today at {0:h:mm tt}", d) - End If - - '' Past - If d.Date < n.Date Then - '' Yesterday - If d.Date = n.Date.AddDays(-1) Then - Return String.Format("Yesterday at {0:h:mm tt}", d) - End If - - '' Last Week - Dim weekStart = n.Date.AddDays(-7) - If d > weekStart Then - Return String.Format("Last {0:dddd} at {0:h:mm tt}", d) - End If - - '' This Year - Dim yearStart = New Date(n.Year, 1, 1) - If d > yearStart Then - '' Weeks - Dim weekNumber As Integer = ((n.DayOfYear - d.DayOfYear) / 7) - Return String.Format("{0} Weeks ago, {1:ddd, d MMM}", weekNumber, d) - End If - End If - - '' Future - If d.Date > n.Date Then - '' Tomorrow - If d.Date = n.Date.AddDays(1) Then - Return String.Format("Tomorrow at {0:h:mm tt}", d) - End If - - '' Next Week - Dim weekEnd = n.Date.AddDays(7) - If d < weekEnd Then - Return String.Format("Next {0:dddd} at {0:h:mm tt}", d) - End If - - '' This Year - Dim nextYearStart = New Date(n.Year + 1, 1, 1) - If d < nextYearStart Then - '' Weeks - Dim weekNumber As Integer = ((d.DayOfYear - n.DayOfYear) / 7) - Return String.Format("In {0} Weeks, {1:ddd, d MMM}", weekNumber, d) - End If - End If - - Return d.ToString("ddd, d MMM yyyy") - - End Function - - Public Function ToFuzzy(d As DateTime?, Optional NullValue As String = "N/A") As String - If d.HasValue Then - Return ToFuzzy(d.Value) - Else - Return NullValue - End If - End Function - - - Public Function ToFullDateTime(d As DateTime) As String - Return d.ToString("ddd, d MMM yyyy @ h:mm:sstt") - End Function - - Public Function ToFullDateTime(d As DateTime?, Optional NullValue As String = "N/A") As String - If d.HasValue Then - Return ToFullDateTime(d.Value) - Else - Return NullValue - End If - End Function - - - Public Function ToJavascriptDate(d As DateTime?, Optional DefaultDate As DateTime? = Nothing) As String - If d.HasValue Then - Return ToJavascriptDate(d.Value) - Else - If DefaultDate.HasValue Then - Return ToJavascriptDate(DefaultDate.Value) - Else - Return "null" - End If - End If - End Function - - Public Function ToJavascriptDate(d As DateTime) As String - Return String.Format("new Date({0}, {1}, {2}, {3}, {4}, {5})", d.Year, d.Month - 1, d.Day, d.Hour, d.Minute, d.Second) - End Function - -#If Not SILVERLIGHT = 1 Then - - Public Function ToSelectListItems(Items As List(Of String), Optional SelectedItem As String = Nothing) As List(Of SelectListItem) - If SelectedItem Is Nothing Then - Return Items.Select(Function(item) New SelectListItem() With {.Value = item, - .Text = item}).ToList() - Else - Return Items.Select(Function(item) New SelectListItem() With {.Value = item, - .Text = item, - .Selected = (item = SelectedItem)}).ToList() - End If - End Function -#End If - - End Module -End Namespace \ No newline at end of file diff --git a/Disco.Silverlight.AttachmentUpload/Views/ErrorWindow.xaml b/Disco.Silverlight.AttachmentUpload/Views/ErrorWindow.xaml deleted file mode 100644 index 96f06c46..00000000 --- a/Disco.Silverlight.AttachmentUpload/Views/ErrorWindow.xaml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - -