narsil/Tanshu.Accounts.Repository/QueryStore.cs
tanshu 3ca8b29e04 Regression: BillItemKey added the compare methods back
Regression: PrintLocation added the compare methods back
Breaking: Kot.Code is now integers
Breaking: Kot Update is now via Stored Procedure to get DB Values
Breaking: Reprints Insert is now via Stored Procedure to get DV Values
Breaking: Voucher.BillID and KotID are now integers
Breaking: Voucher Insert/Update is now via Stored Procedures to get DV Values also Dirty Checking for Voucher has been overwritten to set dirty for LastEditDate update
Fix: Login forms simplified
Feature: PrintLocation and Products are cached application wide.
2014-11-02 13:33:31 +05:30

145 lines
3.7 KiB
C#

using System;
using System.Diagnostics;
using NHibernate;
using NHibernate.SqlCommand;
namespace Tanshu.Accounts.Repository
{
// Add the following in app settings in the config file to enable logging
//<add key="nhibernate-logger" value="Tanshu.Accounts.Repository.EventsLogFactory, Tanshu.Accounts.Repository"/>
public class EventsLogger : IInternalLogger
{
private readonly string _key;
public EventsLogger(string key)
{
_key = key;
}
public bool IsDebugEnabled
{
get { return true; }
}
public bool IsErrorEnabled
{
get { return true; }
}
public bool IsFatalEnabled
{
get { return true; }
}
public bool IsInfoEnabled
{
get { return true; }
}
public bool IsWarnEnabled
{
get { return true; }
}
#region Methods (14)
// Public Methods (14)
public void Debug(object message)
{
if (message == null) return;
var msg = message.ToString();
if (!msg.Contains("oucher") && !_key.Contains("oucher")) return;
Console.WriteLine(string.Format(" -- {0} ---+ {1} +---", _key, DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.ff")));
Console.WriteLine(message.ToString().Trim());
}
public void Debug(object message, Exception exception)
{
if (message == null || exception == null) return;
var msg = message.ToString();
if (!msg.Contains("oucher") && !_key.Contains("oucher")) return;
Console.WriteLine(string.Format(" -- {0} ---+ {1} +---", _key, DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.ff")));
Console.WriteLine(message.ToString().Trim());
Console.WriteLine(exception.ToString());
}
public void DebugFormat(string format, params object[] args)
{
Console.Write(new[]
{
string.Format("---+ {0} +---", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.ff")),
string.Format(format, args),
});
}
public void Error(object message)
{
Debug(message);
}
public void Error(object message, Exception exception)
{
Debug(message, exception);
}
public void ErrorFormat(string format, params object[] args)
{
DebugFormat(format, args);
}
public void Fatal(object message)
{
Debug(message);
}
public void Fatal(object message, Exception exception)
{
Debug(message, exception);
}
public void Info(object message)
{
Debug(message);
}
public void Info(object message, Exception exception)
{
Debug(message, exception);
}
public void InfoFormat(string format, params object[] args)
{
DebugFormat(format, args);
}
public void Warn(object message)
{
Debug(message);
}
public void Warn(object message, Exception exception)
{
Debug(message, exception);
}
public void WarnFormat(string format, params object[] args)
{
DebugFormat(format, args);
}
#endregion Methods
}
public class EventsLogFactory : ILoggerFactory
{
public IInternalLogger LoggerFor(Type type)
{
return new EventsLogger(type.ToString());
}
public IInternalLogger LoggerFor(string keyName)
{
return new EventsLogger(keyName);
}
}
}