public void TestImportHCData() { var sFile = @"D:\he\Doc\20180724发物流人力计算管控系统Dashboard\testData\HCData.xlsx"; var sErr = string.Empty; var nImp = WLE_Data.ImportHCData(new FileInfo(sFile), out sErr); Assert.IsTrue(nImp > 0); Assert.AreEqual(string.Empty, sErr); }
public static bool ImpUpload(string dataType, HttpPostedFileBase file, out string sErrImp) { sErrImp = string.Empty; var fileName = Path.GetFileName(file.FileName); var fileTemp = Path.Combine(GetTempDirBase(), fileName); file.SaveAs(fileTemp); long nRec = 0; try { var fi = new FileInfo(fileTemp); switch (dataType) { case "WeekData": nRec = WLE_Data.ImportWeekData(fi, out sErrImp); break; case "MonthData": nRec = WLE_Data.ImportMonthData(fi, out sErrImp); break; case "HCData": nRec = WLE_Data.ImportHCData(fi, out sErrImp); break; } LogHelper.WriteInfo(typeof(BLLHelper), string.Format("DoUploadCond:{0}", nRec)); } catch (Exception ex) { LogHelper.WriteError(typeof(BLLHelper), ex); sErrImp = string.Format("Excel数据有问题。<br>{0}", ex.Message); } finally { if (CustomConfig.bDeleteTempFile) { File.Delete(fileTemp); } } return(nRec > 0); }