Commit 82f2a8d6 by lizefeng

周转表优化导出

parent 7fefdf41
......@@ -14,19 +14,17 @@ namespace AutoTurnOver.Common
/// </summary>
/// <param name="dt">提供保存数据的DataTable</param>
/// <param name="fileName">CSV的文件路径</param>
public static void SaveCSV(DataTable dt, string fileName, bool existsPush = false)
public static void SaveCSV(DataTable dt, string fileName)
{
// 是否追加
if (!Directory.Exists(Path.GetDirectoryName(fileName)))
{
Directory.CreateDirectory(Path.GetDirectoryName(fileName));
}
FileStream fs = new FileStream(fileName, existsPush?FileMode.OpenOrCreate: FileMode.Create, System.IO.FileAccess.ReadWrite);
FileStream fs = new FileStream(fileName, FileMode.Create, System.IO.FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
string data = "";
if (!existsPush)
{
//写出列名称
for (int i = 0; i < dt.Columns.Count; i++)
{
......@@ -37,7 +35,6 @@ namespace AutoTurnOver.Common
}
}
sw.WriteLine(data);
}
//写出各行数据
......
......@@ -161,12 +161,7 @@ namespace AutoTurnOver.Controllers
var total = 0;
var service = new Services.SkuAutoTurnServices();
int page = 0;
int rows = 10000;
while (true)
{
var list = service.List(m, page, rows, ref total, order, sort);
if (list ==null ||list.Count <= 0) break;
var list = service.List(m, 0, int.MaxValue, ref total, order, sort);
DataTable table = new DataTable();
......@@ -227,9 +222,7 @@ namespace AutoTurnOver.Controllers
}
DataTableHelper.SaveCSV(table, fileName,page>0);
page++;
}
DataTableHelper.SaveCSV(table, fileName);
var memory = new MemoryStream();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment