private void WriteDPLog(DataProcessLog dpl) { string folder = HttpContext.Current.Server.MapPath("~/App_Data/Log/DataProcess/"); DirectoryInfo di = new DirectoryInfo(folder); if (!di.Exists) di.Create(); FileInfo fi = new FileInfo(Path.Combine(di.FullName, String.Format("{0:dd.MM.yyyy}.txt", DateTime.Now))); using (TextWriter tw = new StreamWriter(fi.FullName, true)) tw.WriteLine(String.Format("{0}\t{1}\t{2}\t{3}", dpl.ExecutionStart, dpl.ExecutionEnd, dpl.ExecutionTime, dpl.Command)); }
public DataReturnValue ExecuteReader(string strSqlCommand) { DataProcessLog dpl = new DataProcessLog(); DataReturnValue rv = new DataReturnValue(); try { dpl.ExecutionStart = DateTime.Now; dpl.Command = strSqlCommand; DataSet DS = new DataSet(); DataTable DT = new DataTable(); using (DbCommand Comm = Factory.CreateCommand()) { if (Comm != null) { Comm.CommandText = strSqlCommand; Comm.Connection = Connection; FillParameters(Comm); rv.Value = Comm.ExecuteReader(); } } rv.Status = DataProcessState.Success; } catch (Exception Ex) { rv.Status = DataProcessState.Error; rv.Error = Ex; } Return = rv; WriteLog(Return); dpl.ExecutionEnd = DateTime.Now; dpl.ExecutionTime = dpl.ExecutionStart - dpl.ExecutionEnd; WriteDPLog(dpl); return rv; }