public delegate T UnSafeProcedure<T>();
public string Concat(params object[] arguments)
{
StringBuilder sb = new StringBuilder();
foreach (var item in arguments)
{
sb.AppendFormat("\"{0}\",", item);
}
return sb.ToString();
}
public T RunSafe<T>(UnSafeProcedure<T> s, params object[] arguments)
{
DateTime st = DateTime.Now;
try
{
return s();
}
catch (Exception e1)
{
{
Debug.Write("Error," + Concat(arguments) + "\r\n" + e1.ToString());
}
return default(T);
}
finally
{
var sec = DateTime.Now.Subtract(st).TotalSeconds;
if (sec > 20)
{
string tm = ">20sec,start," + st.ToLongTimeString() + ",End," + DateTime.Now.ToLongTimeString();
Debug.Write(tm+ Concat(arguments));
}
}
}
public Receipt VerifyUser(int Id, string username, string password)
{
return RunSafe<Receipt>(delegate()
{
using (var service = Instance())
{
return service.VerifyAccount(Id, username, password);
}
}, "VerifyUser,facilityId",Id,"username",username,"password",password);
}