public override OutputInvoiceIssuedRecord GetOutputInvoiceIssuedRecord(List <string> list, string month) { OutputInvoiceIssuedRecord ret = new OutputInvoiceIssuedRecord() { TaxRate = list[10], TaxAmount = list[11], Amount = list[9], BuyerName = list[5], BuyerName1 = list[6], EntityCode = list[0], ID = Guid.NewGuid().ToString(), InvoiceCode = list[3], InvoiceNo = list[4], InvoiceStatus = 0, InvoiceType = list[2], IssuedDateTime = list[8], Month = month, Remark = list[1], SerialNumber = null }; if (string.IsNullOrEmpty(ret.Remark)) { ret.Remark = list[7]; } return(ret); }
public void SaveDataBySheetIndex(string fullFilePath, string fileNameWithoutExtension, string month, int sheetIndex) { NPOIDAO dao = new NPOIDAO(); List <List <string> > retData = new List <List <string> >(); using (FileStream fs = File.Open(fullFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { retData = dao.getData(fs, sheetIndex); } List <string> sqlString = new List <string>(); string sqlTemplate = @" INSERT INTO A_BD02([EntityCode],[Month],[SerialNumber],[InvoiceType] ,[InvoiceCode],[InvoiceNo],[BuyerName],[BuyerName1],[Remark],[IssuedDateTime],[Amount],[TaxAmount],[TaxRate],[FileName]) VALUES ({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}); "; foreach (var item in retData) { if (item[0] == "Entity") { continue; } OutputInvoiceIssuedRecord record = this.GetOutputInvoiceIssuedRecord(item, month); string temp = string.Format(sqlTemplate, getStr(record.EntityCode), getStr(record.Month), // month getStr(record.SerialNumber), // SerialNumber getStr(record.InvoiceType), //InvoiceType getStr(record.InvoiceCode), //InvoiceCode getStr(record.InvoiceNo), //InvoiceNo getStr(record.BuyerName), //BuyerName getStr(record.BuyerName1), //BuyerName1 getStr(record.Remark), //Remark getStr(record.IssuedDateTime), //IssuedDateTime getOther(record.Amount), //Amount getOther(record.TaxAmount), //TaxAmount getOther(record.TaxRate), //TaxRate, getStr(fileNameWithoutExtension) ); sqlString.Add(temp); } List <string> saveSql = sqlString.Take(10000).ToList <string>(); this.saveFile(saveSql, 0, fileNameWithoutExtension); int index = 1; while (saveSql.Count == 10000) { saveSql = sqlString.Skip(index * 10000).Take(10000).ToList <string>(); this.saveFile(saveSql, index, fileNameWithoutExtension); index++; } }