Skip to content

Commit

Permalink
Import YALV! v1.3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePet committed Jan 16, 2016
1 parent 2789638 commit 1184138
Show file tree
Hide file tree
Showing 108 changed files with 13,772 additions and 0 deletions.
Binary file added doc/YALV!.docx
Binary file not shown.
Binary file added doc/YALV!.pdf
Binary file not shown.
Binary file added lib/log4net.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions lib/readme.txt
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 added lib/x64/System.Data.SQLite.dll
Binary file not shown.
Binary file added lib/x86/System.Data.SQLite.dll
Binary file not shown.
18 changes: 18 additions & 0 deletions src/YALV.Core/Constants.cs
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");


}
}
111 changes: 111 additions & 0 deletions src/YALV.Core/DataService.cs
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;
}
}
}
}
145 changes: 145 additions & 0 deletions src/YALV.Core/Domain/BindableObject.cs
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

}
}
46 changes: 46 additions & 0 deletions src/YALV.Core/Domain/ColumnItem.cs
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
}
}
61 changes: 61 additions & 0 deletions src/YALV.Core/Domain/DisposableObject.cs
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 { };
}
}
4 changes: 4 additions & 0 deletions src/YALV.Core/Domain/EntriesProviderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace YALV.Core.Domain
{
public enum EntriesProviderType { Xml, Sqlite, MsSqlServer }
}
Loading

0 comments on commit 1184138

Please sign in to comment.