-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
108 changed files
with
13,772 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Download Apache log4net� | ||
http://logging.apache.org/log4net/download.html |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace YALV.Core | ||
{ | ||
public static class Constants | ||
{ | ||
public const string DISPLAY_DATETIME_FORMAT = "MMM d, HH:mm:ss.fff"; | ||
|
||
public const string LAYOUT_LOG4J = "http://jakarta.apache.org/log4j"; | ||
|
||
public const int DEFAULT_REFRESH_INTERVAL = 30; | ||
|
||
public static string FOLDERS_FILE_PATH = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "YALVFolders.xml"); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Xml; | ||
using YALV.Core.Domain; | ||
using YALV.Core.Providers; | ||
|
||
namespace YALV.Core | ||
{ | ||
public static class DataService | ||
{ | ||
public static void SaveFolderFile(IList<PathItem> folders, string path) | ||
{ | ||
FileStream fileStream = null; | ||
StreamWriter streamWriter = null; | ||
try | ||
{ | ||
if (folders != null) | ||
{ | ||
fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); | ||
streamWriter = new StreamWriter(fileStream); | ||
foreach (PathItem item in folders) | ||
{ | ||
string line = String.Format("<folder name=\"{0}\" path=\"{1}\" />", item.Name, item.Path); | ||
streamWriter.WriteLine(line); | ||
} | ||
streamWriter.Close(); | ||
streamWriter = null; | ||
fileStream.Close(); | ||
fileStream = null; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
System.Diagnostics.Trace.TraceError("Error saving Favorites list [{0}]:\r\n{1}\r\n{2}",path,ex.Message,ex.StackTrace); | ||
throw; | ||
} | ||
finally | ||
{ | ||
if (streamWriter != null) | ||
streamWriter.Close(); | ||
if (fileStream != null) | ||
fileStream.Close(); | ||
} | ||
|
||
} | ||
|
||
public static IList<PathItem> ParseFolderFile(string path) | ||
{ | ||
FileStream fileStream = null; | ||
StreamReader streamReader = null; | ||
try | ||
{ | ||
FileInfo fileInfo = new FileInfo(path); | ||
if (!fileInfo.Exists) | ||
return null; | ||
|
||
fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); | ||
streamReader = new StreamReader(fileStream, true); | ||
string sBuffer = String.Format("<root>{0}</root>", streamReader.ReadToEnd()); | ||
streamReader.Close(); | ||
streamReader = null; | ||
fileStream.Close(); | ||
fileStream = null; | ||
|
||
var stringReader = new StringReader(sBuffer); | ||
var xmlTextReader = new XmlTextReader(stringReader) { Namespaces = false }; | ||
|
||
IList<PathItem> result = new List<PathItem>(); | ||
while (xmlTextReader.Read()) | ||
{ | ||
if ((xmlTextReader.NodeType != XmlNodeType.Element) || (xmlTextReader.Name != "folder")) | ||
continue; | ||
|
||
PathItem item = new PathItem(xmlTextReader.GetAttribute("name"), xmlTextReader.GetAttribute("path")); | ||
result.Add(item); | ||
} | ||
return result; | ||
} | ||
catch (Exception ex) | ||
{ | ||
System.Diagnostics.Trace.TraceError("Error parsing Favorites list [{0}]:\r\n{1}\r\n{2}", path, ex.Message, ex.StackTrace); | ||
throw; | ||
} | ||
finally | ||
{ | ||
if (streamReader != null) | ||
streamReader.Close(); | ||
if (fileStream != null) | ||
fileStream.Close(); | ||
} | ||
} | ||
|
||
public static IList<LogItem> ParseLogFile(string path) | ||
{ | ||
IEnumerable<LogItem> result = null; | ||
try | ||
{ | ||
AbstractEntriesProvider provider = EntriesProviderFactory.GetProvider(); | ||
result = provider.GetEntries(path); | ||
return result.ToList(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
System.Diagnostics.Trace.TraceError("Error parsing log file [{0}]:\r\n{1}\r\n{2}", path, ex.Message, ex.StackTrace); | ||
throw; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
|
||
namespace YALV.Core.Domain | ||
{ | ||
/// <summary> | ||
/// INotifyPropertyChange Implementation | ||
/// Implements the INotifyPropertyChanged interface and | ||
/// exposes a RaisePropertyChanged method for derived | ||
/// classes to raise the PropertyChange event. The event | ||
/// arguments created by this class are cached to prevent | ||
/// managed heap fragmentation. | ||
/// Refs: http://www.codeproject.com/KB/WPF/WPF_NHibernate_Validator.aspx | ||
/// </summary> | ||
[Serializable] | ||
public abstract class BindableObject | ||
: DisposableObject, INotifyPropertyChanged | ||
{ | ||
private static readonly Dictionary<string, PropertyChangedEventArgs> _eventArgCache; | ||
private static readonly object _syncLock = new object(); | ||
|
||
#region Constructors | ||
|
||
public BindableObject() | ||
{ | ||
IsPropertyChangedEventEnabled = true; | ||
} | ||
|
||
static BindableObject() | ||
{ | ||
_eventArgCache = new Dictionary<string, PropertyChangedEventArgs>(); | ||
} | ||
|
||
#endregion // Constructors | ||
|
||
#region Pattern Observable | ||
|
||
/// <summary> | ||
/// Raised when a public property of this object is set. | ||
/// </summary> | ||
[field: NonSerialized] | ||
public virtual event PropertyChangedEventHandler PropertyChanged; | ||
|
||
/// <summary> | ||
/// Indica se è abilitata la notifica del cambiamento di proprietà | ||
/// </summary> | ||
public virtual bool IsPropertyChangedEventEnabled { get; set; } | ||
|
||
/// <summary> | ||
/// Returns an instance of PropertyChangedEventArgs for | ||
/// the specified property name. | ||
/// </summary> | ||
/// <param name="propertyName"> | ||
/// The name of the property to create event args for. | ||
/// </param> | ||
public static PropertyChangedEventArgs GetPropertyChangedEventArgs(string propertyName) | ||
{ | ||
if (String.IsNullOrEmpty(propertyName)) | ||
throw new ArgumentException("propertyName cannot be null or empty."); | ||
|
||
PropertyChangedEventArgs args; | ||
lock (BindableObject._syncLock) | ||
{ | ||
if (!_eventArgCache.TryGetValue(propertyName, out args)) | ||
{ | ||
_eventArgCache.Add(propertyName, args = new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
return args; | ||
} | ||
|
||
/// <summary> | ||
/// Attempts to raise the PropertyChanged event, and | ||
/// invokes the virtual AfterPropertyChanged method, | ||
/// regardless of whether the event was raised or not. | ||
/// </summary> | ||
/// <param name="propertyName"> | ||
/// The property which was changed. | ||
/// </param> | ||
public virtual void RaisePropertyChanged(string propertyName) | ||
{ | ||
//Se non è abilitata la notifica del cambiamento di proprietà allora non faccio niente | ||
if (!IsPropertyChangedEventEnabled) | ||
return; | ||
|
||
this.VerifyProperty(propertyName); | ||
|
||
PropertyChangedEventHandler handler = this.PropertyChanged; | ||
if (handler != null) | ||
{ | ||
//Get the cached event args. | ||
PropertyChangedEventArgs args = | ||
GetPropertyChangedEventArgs(propertyName); | ||
|
||
// Raise the PropertyChanged event. | ||
handler(this, args); | ||
} | ||
this.OnAfterPropertyChanged(propertyName); | ||
} | ||
|
||
/// <summary> | ||
/// Derived classes can override this method to | ||
/// execute logic after a property is set. The | ||
/// base implementation does nothing. | ||
/// </summary> | ||
/// <param name="propertyName"> | ||
/// The property which was changed. | ||
/// </param> | ||
protected virtual void OnAfterPropertyChanged(string propertyName) { } | ||
|
||
#endregion | ||
|
||
#region Helpers | ||
|
||
[Conditional("DEBUG")] | ||
private void VerifyProperty(string propertyName) | ||
{ | ||
if (propertyName.IndexOf(".") >= 0) | ||
return; | ||
|
||
// Thanks to Rama Krishna Vavilala for the tip to use TypeDescriptor here, instead of manual | ||
// reflection, so that custom properties are honored too. | ||
// http://www.codeproject.com/KB/WPF/podder1.aspx?msg=2381272#xx2381272xx | ||
|
||
bool propertyExists = TypeDescriptor.GetProperties(this).Find(propertyName, false) != null; | ||
if (!propertyExists) | ||
{ | ||
// The property could not be found, | ||
// so alert the developer of the problem. | ||
|
||
string msg = string.Format( | ||
"{0} is not a public property of {1}", | ||
propertyName, | ||
this.GetType().FullName); | ||
|
||
Debug.Fail(msg); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
|
||
namespace YALV.Core.Domain | ||
{ | ||
[Serializable] | ||
public class ColumnItem | ||
{ | ||
public string Header { get; set; } | ||
public string Field { get; set; } | ||
public string StringFormat { get; set; } | ||
public double? MinWidth { get; set; } | ||
public double? Width { get; set; } | ||
public CellAlignment Alignment { get; set; } | ||
|
||
public ColumnItem(string field, double? minWidth, double? width) | ||
: this(field, minWidth, width, CellAlignment.DEFAULT, string.Empty, field) | ||
{ | ||
} | ||
|
||
public ColumnItem(string field, double? minWidth, double? width, CellAlignment align) | ||
: this(field, minWidth, width, align, string.Empty, field) | ||
{ | ||
} | ||
|
||
public ColumnItem(string field, double? minWidth, double? width, CellAlignment align, string stringFormat) | ||
: this(field, minWidth, width, align, stringFormat, field) | ||
{ | ||
} | ||
|
||
public ColumnItem(string field, double? minWidth, double? width, CellAlignment align, string stringFormat, string header) | ||
{ | ||
Field = field; | ||
MinWidth = minWidth; | ||
Width = width; | ||
Alignment = align; | ||
StringFormat = stringFormat; | ||
Header = header; | ||
} | ||
} | ||
|
||
public enum CellAlignment | ||
{ | ||
DEFAULT = 0, | ||
CENTER = 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
|
||
namespace YALV.Core.Domain | ||
{ | ||
/// <summary> | ||
/// "Implementing a Dispose method" | ||
/// http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx | ||
/// </summary> | ||
public class DisposableObject | ||
: IDisposable | ||
{ | ||
protected bool _disposed; | ||
|
||
public DisposableObject() | ||
{ | ||
} | ||
|
||
public DisposableObject(Action action) | ||
{ | ||
Disposed = action; | ||
} | ||
|
||
~DisposableObject() | ||
{ | ||
Dispose(false); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
|
||
// Use SupressFinalize in case a subclass | ||
// of this type implements a finalizer. | ||
GC.SuppressFinalize(this); | ||
|
||
//Raise disposed event | ||
if (Disposed != null) | ||
Disposed(); | ||
} | ||
|
||
protected void Dispose(bool disposing) | ||
{ | ||
// If you need thread safety, use a lock around these | ||
// operations, as well as in your methods that use the resource. | ||
if (!_disposed) | ||
{ | ||
if (disposing) | ||
{ | ||
OnDispose(); | ||
} | ||
|
||
// Indicate that the instance has been disposed. | ||
_disposed = true; | ||
} | ||
} | ||
|
||
protected virtual void OnDispose() { } | ||
|
||
public event Action Disposed = delegate { }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace YALV.Core.Domain | ||
{ | ||
public enum EntriesProviderType { Xml, Sqlite, MsSqlServer } | ||
} |
Oops, something went wrong.