diff --git a/CHANGELOG.md b/CHANGELOG.md
index 79c58f1..b4bdd81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
# Version history
+---------------------------------------------------------------------------------------
+## [v4.2.3](https://github.com/Behzadkhosravifar/ErrorControlSystem/archive/v4.2.3.zip)
+
+Added
+
+ * Some Bug fixes
+ * Add LogOnTheFly option to logging errors without caching on local systems
+
---------------------------------------------------------------------------------------
## [v4.2.2](https://github.com/Behzadkhosravifar/ErrorControlSystem/archive/v4.2.2.zip)
diff --git a/src/.nuget/ErrorControlSystem.nuspec b/src/.nuget/ErrorControlSystem.nuspec
index dc82428..7272498 100644
--- a/src/.nuget/ErrorControlSystem.nuspec
+++ b/src/.nuget/ErrorControlSystem.nuspec
@@ -6,7 +6,7 @@
https://raw.githubusercontent.com/Behzadkhosravifar/ErrorControlSystem/master/src/Documentation/Readme/images/Error%20Control%20System.png
- 4.2.2
+ 4.2.3
ErrorControlSystem is a .NET library created to automate handling .NET Windows-Base application exceptions and raise that to a sql server. This exception handler have some features as screen capturing, fetch server date time in exception occurrence time and etc.
@@ -21,11 +21,13 @@
* Some Bug fixes
+ * Add StoredProcedure for catching Sql Errors (sp_CatchError issue #54)
* Remove SqlServerCe nuget reference dependency
* Fix clickOnce additional problem
-
+ * Add LogOnTheFly option to logging errors without caching on local systems
+
More Info: https://github.com/Behzadkhosravifar/ErrorControlSystem/releases
-
+
Copyright (C) 2015 Behzad Khosravifar
diff --git a/src/Error Control System/ErrorControlSystem/CacheErrors/CacheController.cs b/src/Error Control System/ErrorControlSystem/CacheErrors/CacheController.cs
index 69dd66a..fbbdb5e 100644
--- a/src/Error Control System/ErrorControlSystem/CacheErrors/CacheController.cs
+++ b/src/Error Control System/ErrorControlSystem/CacheErrors/CacheController.cs
@@ -17,7 +17,7 @@ internal static class CacheController
public static SqlCompactEditionManager SdfManager { get; private set; }
- public static ActionBlock> AcknowledgeActionBlock;
+ public static ActionBlock> AcknowledgeActionBlock;
private static ActionBlock _errorSaverActionBlock;
@@ -36,7 +36,7 @@ static CacheController()
#region Acknowledge Action Block
- AcknowledgeActionBlock = new ActionBlock>(
+ AcknowledgeActionBlock = new ActionBlock>(
async ack =>
{
if (ack.Item2) // Error Successful sent to server database
@@ -46,7 +46,8 @@ static CacheController()
await SdfManager.DeleteAsync(ack.Item1.Id);
//
// De-story error from Memory (RAM):
- if (ack.Item1 != null) ack.Item1.Dispose();
+ var error = ack.Item1 as ProxyError;
+ if (error != null) error.Dispose();
}
},
new ExecutionDataflowBlockOptions
@@ -98,7 +99,7 @@ public static async Task UploadCacheAsync()
foreach (var error in errors)
{
- await ServerTransmitter.ErrorListenerTransformBlock.SendAsync(new ProxyError(error));
+ await ServerTransmitter.ErrorListenerTransformBlock.SendAsync(error);
if (!ErrorHandlingOption.EnableNetworkSending) break;
}
@@ -128,6 +129,9 @@ public static async void CacheTheError(Error error)
await _errorSaverActionBlock.SendAsync(error);
}
+
+
+
#endregion
}
}
\ No newline at end of file
diff --git a/src/Error Control System/ErrorControlSystem/ExceptionHandler.cs b/src/Error Control System/ErrorControlSystem/ExceptionHandler.cs
index f0bcf3b..fe68ab9 100644
--- a/src/Error Control System/ErrorControlSystem/ExceptionHandler.cs
+++ b/src/Error Control System/ErrorControlSystem/ExceptionHandler.cs
@@ -21,6 +21,7 @@
using System.Globalization;
+using ErrorControlSystem.ServerController;
namespace ErrorControlSystem
{
@@ -43,8 +44,6 @@ public static partial class ExceptionHandler
{
#region Properties
- internal static bool AssembelyLoaded { get; set; }
-
///
/// Represents the method that will handle the event raised by an exception that is not handled by the application domain.
///
@@ -65,15 +64,6 @@ static ExceptionHandler()
#region Methods
- internal static void LoadAssemblies()
- {
- //EmbeddedAssembly.Load("System.Data.SqlServerCe.dll");
- //EmbeddedAssembly.Load("System.Threading.Tasks.Dataflow.dll");
- //AppDomain.CurrentDomain.AssemblyResolve += (s, e) => EmbeddedAssembly.Get(e.Name);
-
- AssembelyLoaded = true;
- }
-
///
/// Raise log of handled error's.
///
@@ -142,7 +132,14 @@ private static ProcessFlow UnhandledExceptionLogger(Exception exp, StackFrame[]
var error = new Error(exp, callStackFrames, snapshot) { IsHandled = false };
//
// Store Error object
- CacheController.CacheTheError(error);
+ if (ErrorHandlingOption.LogOnTheFly)
+ {
+ Task.Run(async () => await error.SendToServer());
+ }
+ else
+ {
+ CacheController.CacheTheError(error);
+ }
//
// Handle 'OnShowUnhandledError' events
OnShowUnhandledError(exp, new UnhandledErrorEventArgs(error));
@@ -203,7 +200,16 @@ private static ProcessFlow HandledExceptionLogger(Exception exp, StackFrame[] ca
// initial the error object by additional data
var error = new Error(exp, callStackFrames, snapshot);
- CacheController.CacheTheError(error);
+ //
+ // Store Error object
+ if (ErrorHandlingOption.LogOnTheFly)
+ {
+ Task.Run(async () => await error.SendToServer());
+ }
+ else
+ {
+ CacheController.CacheTheError(error);
+ }
return ProcessFlow.Continue;
}
diff --git a/src/Error Control System/ErrorControlSystem/Properties/GlobalAssemblyInfo.cs b/src/Error Control System/ErrorControlSystem/Properties/GlobalAssemblyInfo.cs
index b11ccef..826af15 100644
--- a/src/Error Control System/ErrorControlSystem/Properties/GlobalAssemblyInfo.cs
+++ b/src/Error Control System/ErrorControlSystem/Properties/GlobalAssemblyInfo.cs
@@ -41,12 +41,12 @@
// 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: System.Reflection.AssemblyVersion("4.2.2")]
+[assembly: System.Reflection.AssemblyVersion("4.2.3")]
// This is also assigned to 'AssemblyInformationalVersion' which is the product version
// Standard Way: [major].[minor].[bugfix].[build]
// .NET Convention: Third digit is the auto-incremented build version. Fourth digit is revision, which is service pack no
-[assembly: System.Reflection.AssemblyFileVersion("4.2.2")]
+[assembly: System.Reflection.AssemblyFileVersion("4.2.3")]
/*
* AssemblyVersion should only be changed for major changes or breaking changes since any change to the
* AssemblyVersion would force every .NET application referencing the assembly to re-compile against the
diff --git a/src/Error Control System/ErrorControlSystem/ServerController/ServerTransmitter.cs b/src/Error Control System/ErrorControlSystem/ServerController/ServerTransmitter.cs
index d2d66c9..3c3db73 100644
--- a/src/Error Control System/ErrorControlSystem/ServerController/ServerTransmitter.cs
+++ b/src/Error Control System/ErrorControlSystem/ServerController/ServerTransmitter.cs
@@ -15,7 +15,7 @@ public static partial class ServerTransmitter
{
#region Properties
- public static TransformBlock> ErrorListenerTransformBlock;
+ public static TransformBlock> ErrorListenerTransformBlock;
#endregion
@@ -29,7 +29,7 @@ public static async Task InitialTransmitterAsync()
{
await ServerValidatorAsync();
- ErrorListenerTransformBlock = new TransformBlock>(
+ ErrorListenerTransformBlock = new TransformBlock>(
async (e) => await TransmitOneError(e),
new ExecutionDataflowBlockOptions()
{
@@ -71,7 +71,7 @@ private static async Task ServerValidatorAsync()
}
[DebuggerStepThrough]
- private static async Task> TransmitOneError(ProxyError error)
+ private static async Task> TransmitOneError(IError error)
{
if (ErrorHandlingOption.EnableNetworkSending) // Server Connector to online or offline ?
{
@@ -105,7 +105,15 @@ private static async Task> TransmitOneError(ProxyError e
ErrorHandlingOption.AtSentState = false;
//
// Post to Acknowledge Action Block:
- return new Tuple(error, ErrorHandlingOption.EnableNetworkSending);
+ return new Tuple(error, ErrorHandlingOption.EnableNetworkSending);
+ }
+
+
+ public static async Task SendToServer(this IError error)
+ {
+ var result = await TransmitOneError(error);
+
+ return result.Item2;
}
#endregion
diff --git a/src/Error Control System/ErrorControlSystem/ServerController/SqlServerManager.cs b/src/Error Control System/ErrorControlSystem/ServerController/SqlServerManager.cs
index 04e4195..f6e31d0 100644
--- a/src/Error Control System/ErrorControlSystem/ServerController/SqlServerManager.cs
+++ b/src/Error Control System/ErrorControlSystem/ServerController/SqlServerManager.cs
@@ -79,7 +79,7 @@ public static async Task CreateTablesAndStoredProceduresAsync()
}
}
- public static async Task InsertErrorAsync(ProxyError error)
+ public static async Task InsertErrorAsync(IError error)
{
// Create a command object identifying the stored procedure
using (var cmd = new SqlCommand("sp_InsertErrorLog"))
@@ -89,8 +89,8 @@ public static async Task InsertErrorAsync(ProxyError error)
cmd.CommandType = CommandType.StoredProcedure;
//
// Add parameters to command, which will be passed to the stored procedure
- if (error.Snapshot.Value != null)
- cmd.Parameters.AddWithValue("@ScreenCapture", error.Snapshot.Value.ToBytes());
+ if (error.Snapshot != null)
+ cmd.Parameters.AddWithValue("@ScreenCapture", error.Snapshot.ToBytes());
cmd.Parameters.AddWithValue("@ServerDateTime", error.ServerDateTime);
diff --git a/src/Error Control System/ErrorControlSystem/Shared/Error.cs b/src/Error Control System/ErrorControlSystem/Shared/Error.cs
index 77d7980..d9492b8 100644
--- a/src/Error Control System/ErrorControlSystem/Shared/Error.cs
+++ b/src/Error Control System/ErrorControlSystem/Shared/Error.cs
@@ -14,9 +14,7 @@ namespace ErrorControlSystem.Shared
public class Error : IError, IDisposable, ICloneable
{
#region Properties
-
- public System.Drawing.Image Snapshot { get; set; }
-
+
///
/// Dictionary of key/value data that will be stored in exceptions as additional data.
///
@@ -227,6 +225,7 @@ public Error() { }
public CodeScope LineColumn { get; set; }
public int Duplicate { get; set; }
public string Data { get; set; }
+ public System.Drawing.Image Snapshot { get; set; }
#endregion
#region IDisposable Implement
diff --git a/src/Error Control System/ErrorControlSystem/Shared/IError.cs b/src/Error Control System/ErrorControlSystem/Shared/IError.cs
index 381b206..430e73f 100644
--- a/src/Error Control System/ErrorControlSystem/Shared/IError.cs
+++ b/src/Error Control System/ErrorControlSystem/Shared/IError.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Drawing;
namespace ErrorControlSystem.Shared
{
@@ -29,5 +30,6 @@ public interface IError : IEquatable
CodeScope LineColumn { get; set; }
int Duplicate { get; set; }
String Data { get; set; }
+ System.Drawing.Image Snapshot { get; }
}
}
\ No newline at end of file
diff --git a/src/Error Control System/ErrorControlSystem/Shared/ProxyError.cs b/src/Error Control System/ErrorControlSystem/Shared/ProxyError.cs
index b90fbc1..058deb0 100644
--- a/src/Error Control System/ErrorControlSystem/Shared/ProxyError.cs
+++ b/src/Error Control System/ErrorControlSystem/Shared/ProxyError.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections;
-using System.Collections.Generic;
using System.Drawing;
using System.Runtime.Serialization;
using ErrorControlSystem.CacheErrors;
@@ -12,7 +10,7 @@ public class ProxyError : IError, IDisposable, ICloneable, ISerializable
{
#region Properties
- public Lazy Snapshot { get; set; }
+ public Lazy LazySnapshot { get; set; }
#endregion
@@ -20,10 +18,10 @@ public class ProxyError : IError, IDisposable, ICloneable, ISerializable
public ProxyError()
{
- #region Initialize Lazy Snapshot
+ #region Initialize Lazy LazySnapshot
// Initialize by invoking a specific constructor on Order when Value property is accessed
- Snapshot = new Lazy(() => CacheController.SdfManager.GetSnapshot(Id));
+ LazySnapshot = new Lazy(() => CacheController.SdfManager.GetSnapshot(Id));
#endregion
}
@@ -62,7 +60,7 @@ public ProxyError(IError error)
#region Initialize Lazy Snapshot
// Initialize by invoking a specific constructor on Order when Value property is accessed
- Snapshot = new Lazy(() => CacheController.SdfManager.GetSnapshot(Id));
+ LazySnapshot = new Lazy(() => CacheController.SdfManager.GetSnapshot(Id));
#endregion
}
@@ -95,7 +93,7 @@ public ProxyError(SerializationInfo info, StreamingContext ctxt)
Duplicate = (int)info.GetValue("Duplicate", typeof(int));
Data = (string)info.GetValue("Data", typeof(string));
// Initialize by invoking a specific constructor on Order when Value property is accessed
- Snapshot = new Lazy(() => CacheController.SdfManager.GetSnapshot(Id));
+ LazySnapshot = new Lazy(() => CacheController.SdfManager.GetSnapshot(Id));
}
#endregion
@@ -129,7 +127,7 @@ public static implicit operator Error(ProxyError proxyError)
User = proxyError.User,
LineColumn = proxyError.LineColumn,
Duplicate = proxyError.Duplicate,
- Snapshot = proxyError.Snapshot.Value,
+ Snapshot = proxyError.Snapshot,
Data = proxyError.Data
};
}
@@ -166,6 +164,7 @@ public static explicit operator ProxyError(Error error)
public CodeScope LineColumn { get; set; }
public int Duplicate { get; set; }
public string Data { get; set; }
+ public System.Drawing.Image Snapshot { get { return LazySnapshot.Value; } }
#endregion
#region IDisposable Implement
@@ -189,7 +188,7 @@ public void Dispose()
OS = null;
Processes = null;
ServerDateTime = DateTime.MinValue;
- Snapshot = null;
+ LazySnapshot = null;
Source = String.Empty;
StackTrace = String.Empty;
User = String.Empty;
diff --git a/src/Error Log Analyzer/ErrorLogAnalyzer/LogReader.cs b/src/Error Log Analyzer/ErrorLogAnalyzer/LogReader.cs
index c5175e4..d80179e 100644
--- a/src/Error Log Analyzer/ErrorLogAnalyzer/LogReader.cs
+++ b/src/Error Log Analyzer/ErrorLogAnalyzer/LogReader.cs
@@ -240,7 +240,7 @@ private void dgv_ErrorsViewer_SelectionChanged(object sender, EventArgs e)
{
var currentRow = DynamicDgv.GetCurrentRow();
if (currentRow != null)
- pictureBox_viewer.Image = currentRow.Snapshot.Value ?? Properties.Resources._null;
+ pictureBox_viewer.Image = currentRow.Snapshot ?? Properties.Resources._null;
});
}
diff --git a/src/Examples/ErrorControlSystem.Examples.WinForms/Program.cs b/src/Examples/ErrorControlSystem.Examples.WinForms/Program.cs
index e8e883a..ac1b193 100644
--- a/src/Examples/ErrorControlSystem.Examples.WinForms/Program.cs
+++ b/src/Examples/ErrorControlSystem.Examples.WinForms/Program.cs
@@ -23,6 +23,7 @@ private static void Main()
// Or Set Option this way:
ErrorHandlingOption.ResizeSnapshots = false;
ErrorHandlingOption.ReportHandledExceptions = true;
+ ErrorHandlingOption.LogOnTheFly = true; // don't cache
//
// Some of the optional configuration items.