public void ExportExcel() { PerformanceHelper ph = new PerformanceHelper(); ph.Start("取数时间"); var list = YK.Service.AdminService.LogService.Search(); ph.Stop(); ph.Start("导出时间"); var teamplatePath = Server.MapPath("~/老客户列表.xlsx"); var savePath1 = Server.MapPath("~/products1.xlsx"); var savePath2 = Server.MapPath("~/products2.xlsx"); var savePath3 = Server.MapPath("~/products3.xlsx"); var savePath4 = Server.MapPath("~/products4.xlsx"); var savePath5 = Server.MapPath("~/products5.xlsx"); var savePath6 = Server.MapPath("~/products6.xlsx"); YK.Common.Excel.ExcelHelper helper = new YK.Common.Excel.ExcelHelper(); helper.DataRowStart = 2; helper.DataColumnStart = 0; helper.Export(list.Skip(20000 * 0).Take(20000), teamplatePath, savePath1); helper.Export(list.Skip(20000 * 1).Take(20000), teamplatePath, savePath2); helper.Export(list.Skip(20000 * 2).Take(20000), teamplatePath, savePath3); helper.Export(list.Skip(20000 * 3).Take(20000), teamplatePath, savePath4); helper.Export(list.Skip(20000 * 4).Take(20000), teamplatePath, savePath5); helper.Export(list.Skip(20000 * 5).Take(20000), teamplatePath, savePath6); ph.Stop(); }
protected void Page_Load2(object sender, EventArgs e) { list = YK.Service.AdminService.LogService.Search(); PerformanceHelper ph = new PerformanceHelper(); ph.Start("取数时间"); Thread t1 = new Thread(new ParameterizedThreadStart(ExportExcel)); Thread t2 = new Thread(new ParameterizedThreadStart(ExportExcel)); Thread t3 = new Thread(new ParameterizedThreadStart(ExportExcel)); Thread t4 = new Thread(new ParameterizedThreadStart(ExportExcel)); Thread t5 = new Thread(new ParameterizedThreadStart(ExportExcel)); Thread t6 = new Thread(new ParameterizedThreadStart(ExportExcel)); t1.Start(1); t2.Start(2); t3.Start(3); t4.Start(4); t5.Start(5); t6.Start(6); ph.Stop(); Thread.Sleep(60000); ExportZip(); }
static void CypressFlashMemorySample(ISPI spi) { var flash = new CypressFlashMemory(spi); flash.ReadIdentification(); System.Console.WriteLine(flash.GetDeviceInfo()); var _64kAbdcString = PerformanceHelper.Get64kStringAbcd(); var _64kAbdcBuffer = PerformanceHelper.GetAsciiBuffer(_64kAbdcString).ToList(); var _64kFredString = PerformanceHelper.Get64kStringFred(); var _64kFredBuffer = PerformanceHelper.GetAsciiBuffer(_64kFredString).ToList(); var _64k0123String = PerformanceHelper.Get64kString0123(); var _64k0123Buffer = PerformanceHelper.GetAsciiBuffer(_64k0123String).ToList(); var ph = new PerformanceHelper(); var WRITE_FLASH = false; if (WRITE_FLASH) { // flash.FormatFlash((done) => { System.Console.WriteLine($"{done} formatted"); }); // Write the 16 Mb of FLASH using 64k string // Each block or page must be erased before being written ph.Start(); for (var _64kBlock = 10; _64kBlock < flash.MaxBlock; _64kBlock++) { ph.AddByte(CypressFlashMemory.BLOCK_SIZE); System.Console.WriteLine($"Writing block:{_64kBlock}/{flash.MaxBlock}, {_64kBlock * 100.0 / flash.MaxBlock:0}%"); var r = false; if (_64kBlock == 10) { r = flash.WritePages(_64kBlock * CypressFlashMemory.BLOCK_SIZE, _64k0123Buffer, format: true); } else { if (_64kBlock % 2 == 0) { r = flash.WritePages(_64kBlock * CypressFlashMemory.BLOCK_SIZE, _64kAbdcBuffer, format: true); } else { r = flash.WritePages(_64kBlock * CypressFlashMemory.BLOCK_SIZE, _64kFredBuffer, format: true); } } if (!r) { System.Console.WriteLine($"Error writing block:{_64kBlock}"); } } ph.Stop(); System.Console.WriteLine($"Write Operation:{ph.GetResultInfo()}"); System.Console.ReadKey(); } // Read the 16 Mb of FLASH and verify result ph = new PerformanceHelper(); ph.Start(); for (var _64kBlock = 10; _64kBlock < flash.MaxBlock; _64kBlock++) { System.Console.WriteLine($"Reading block:{_64kBlock}/{flash.MaxBlock}, {_64kBlock*100.0/flash.MaxBlock:0}%"); var buffer = new List <byte>(); if (flash.ReadPages(_64kBlock * CypressFlashMemory.BLOCK_SIZE, CypressFlashMemory.BLOCK_SIZE, buffer)) { var resultString = PerformanceHelper.AsciiBufferToString(buffer.ToArray()); ph.AddByte(CypressFlashMemory.BLOCK_SIZE); var result = false; if (_64kBlock % 2 == 0) { result = (resultString == _64kAbdcString); System.Console.WriteLine($"Reading block:{_64kBlock}, Status:{result}"); } else { result = (resultString == _64kFredString); System.Console.WriteLine($"Reading block:{_64kBlock}, Status:{result}"); } if (!result && Debugger.IsAttached) { Debugger.Break(); } } } ph.Stop(); System.Console.WriteLine($"Read Operation:{ph.GetResultInfo()}"); System.Console.ReadKey(); }