Skip to content

Commit

Permalink
Release ver4.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Sep 18, 2015
1 parent 26d2db9 commit fa8414c
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 42 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 5 additions & 3 deletions src/.nuget/ErrorControlSystem.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<iconUrl>
https://raw.githubusercontent.com/Behzadkhosravifar/ErrorControlSystem/master/src/Documentation/Readme/images/Error%20Control%20System.png
</iconUrl>
<version>4.2.2</version>
<version>4.2.3</version>
<description>
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.
</description>
Expand All @@ -21,11 +21,13 @@
<releaseNotes>

* 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

</releaseNotes>
<copyright>Copyright (C) 2015 Behzad Khosravifar</copyright>
<tags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static class CacheController

public static SqlCompactEditionManager SdfManager { get; private set; }

public static ActionBlock<Tuple<ProxyError, bool>> AcknowledgeActionBlock;
public static ActionBlock<Tuple<IError, bool>> AcknowledgeActionBlock;

private static ActionBlock<Error> _errorSaverActionBlock;

Expand All @@ -36,7 +36,7 @@ static CacheController()

#region Acknowledge Action Block

AcknowledgeActionBlock = new ActionBlock<Tuple<ProxyError, bool>>(
AcknowledgeActionBlock = new ActionBlock<Tuple<IError, bool>>(
async ack =>
{
if (ack.Item2) // Error Successful sent to server database
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -128,6 +129,9 @@ public static async void CacheTheError(Error error)
await _errorSaverActionBlock.SendAsync(error);
}




#endregion
}
}
32 changes: 19 additions & 13 deletions src/Error Control System/ErrorControlSystem/ExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


using System.Globalization;
using ErrorControlSystem.ServerController;

namespace ErrorControlSystem
{
Expand All @@ -43,8 +44,6 @@ public static partial class ExceptionHandler
{
#region Properties

internal static bool AssembelyLoaded { get; set; }

/// <summary>
/// Represents the method that will handle the event raised by an exception that is not handled by the application domain.
/// </summary>
Expand All @@ -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;
}

/// <summary>
/// Raise log of handled error's.
/// </summary>
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static partial class ServerTransmitter
{
#region Properties

public static TransformBlock<ProxyError, Tuple<ProxyError, bool>> ErrorListenerTransformBlock;
public static TransformBlock<IError, Tuple<IError, bool>> ErrorListenerTransformBlock;

#endregion

Expand All @@ -29,7 +29,7 @@ public static async Task InitialTransmitterAsync()
{
await ServerValidatorAsync();

ErrorListenerTransformBlock = new TransformBlock<ProxyError, Tuple<ProxyError, bool>>(
ErrorListenerTransformBlock = new TransformBlock<IError, Tuple<IError, bool>>(
async (e) => await TransmitOneError(e),
new ExecutionDataflowBlockOptions()
{
Expand Down Expand Up @@ -71,7 +71,7 @@ private static async Task ServerValidatorAsync()
}

[DebuggerStepThrough]
private static async Task<Tuple<ProxyError, bool>> TransmitOneError(ProxyError error)
private static async Task<Tuple<IError, bool>> TransmitOneError(IError error)
{
if (ErrorHandlingOption.EnableNetworkSending) // Server Connector to online or offline ?
{
Expand Down Expand Up @@ -105,7 +105,15 @@ private static async Task<Tuple<ProxyError, bool>> TransmitOneError(ProxyError e
ErrorHandlingOption.AtSentState = false;
//
// Post to Acknowledge Action Block:
return new Tuple<ProxyError, bool>(error, ErrorHandlingOption.EnableNetworkSending);
return new Tuple<IError, bool>(error, ErrorHandlingOption.EnableNetworkSending);
}


public static async Task<bool> SendToServer(this IError error)
{
var result = await TransmitOneError(error);

return result.Item2;
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/Error Control System/ErrorControlSystem/Shared/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ namespace ErrorControlSystem.Shared
public class Error : IError, IDisposable, ICloneable
{
#region Properties

public System.Drawing.Image Snapshot { get; set; }


/// <summary>
/// Dictionary of key/value data that will be stored in exceptions as additional data.
/// </summary>
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Error Control System/ErrorControlSystem/Shared/IError.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;

namespace ErrorControlSystem.Shared
{
Expand Down Expand Up @@ -29,5 +30,6 @@ public interface IError : IEquatable<IError>
CodeScope LineColumn { get; set; }
int Duplicate { get; set; }
String Data { get; set; }
System.Drawing.Image Snapshot { get; }
}
}
17 changes: 8 additions & 9 deletions src/Error Control System/ErrorControlSystem/Shared/ProxyError.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.Serialization;
using ErrorControlSystem.CacheErrors;
Expand All @@ -12,18 +10,18 @@ public class ProxyError : IError, IDisposable, ICloneable, ISerializable
{
#region Properties

public Lazy<System.Drawing.Image> Snapshot { get; set; }
public Lazy<System.Drawing.Image> LazySnapshot { get; set; }

#endregion

#region Constructor

public ProxyError()
{
#region Initialize Lazy<Image> Snapshot
#region Initialize Lazy<Image> LazySnapshot

// Initialize by invoking a specific constructor on Order when Value property is accessed
Snapshot = new Lazy<Image>(() => CacheController.SdfManager.GetSnapshot(Id));
LazySnapshot = new Lazy<Image>(() => CacheController.SdfManager.GetSnapshot(Id));

#endregion
}
Expand Down Expand Up @@ -62,7 +60,7 @@ public ProxyError(IError error)
#region Initialize Lazy<Image> Snapshot

// Initialize by invoking a specific constructor on Order when Value property is accessed
Snapshot = new Lazy<Image>(() => CacheController.SdfManager.GetSnapshot(Id));
LazySnapshot = new Lazy<Image>(() => CacheController.SdfManager.GetSnapshot(Id));

#endregion
}
Expand Down Expand Up @@ -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<Image>(() => CacheController.SdfManager.GetSnapshot(Id));
LazySnapshot = new Lazy<Image>(() => CacheController.SdfManager.GetSnapshot(Id));
}

#endregion
Expand Down Expand Up @@ -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
};
}
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Error Log Analyzer/ErrorLogAnalyzer/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fa8414c

Please sign in to comment.