public IReply Execute() { ReplyDataTable reply = new ReplyDataTable { Value = new DataTable() }; try { _command.Connection.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter(_command)) { adapter.Fill(reply.Value); } } catch (Exception ex) { reply.ErrorMessage = ex.ToLogString(); } finally { if (_command.Connection.State == ConnectionState.Open) { _command.Connection.Close(); } } reply.Condition = reply.ErrorMessage.IsEmpty(); return(reply); }
public void Execute() { using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[_connectionName].ToString())) using (SqlCommand sqlCommand = new SqlCommand(_sqlQuery, connection)) { sqlCommand.CommandTimeout = 240; FillTable fillTable = new FillTable(sqlCommand); ReplyDataTable outcome = (ReplyDataTable)fillTable.Execute(); if (outcome.Condition) { String localFileName = "{0} {1}.csv".FormatX(_filename, DateTime.Now.ToString("yyyy MM dd (dddd)")); FileInfo extractFile = new FileInfo(Path.Combine(_folder, localFileName)); WriteToTextFile exportToFile = new WriteToTextFile(outcome.Value, extractFile, true); exportToFile.Execute(); } } }
public IReply Execute() { ReplyDataTable reply = new ReplyDataTable(); try { using (FileStream outputFile = new FileStream(_outputFilePath.FullName, FileMode.Create)) { _writer.WriteToStream(_dataSource, outputFile); outputFile.Close(); } } catch (Exception ex) { reply.ErrorMessage = ex.ToLogString(); } return(reply); }