protected void btnImport_Click(object sender, EventArgs e) { DateTime finishTime=Convert.ToDateTime(tbxFinishTime.Text.Trim()); ImportOperationLog il = new ImportOperationLog(); string fileNames=string.Empty; foreach(DirectoryInfo dir in GetImportedDir()) { fileNames+=dir.Name+"|"; } fileNames = fileNames.TrimEnd('|'); try { ProductImportor importor = new ProductImportor(true); //importor.CheckWithDatabase = true; importor.WebProductImagesPath = Server.MapPath("/ProductImages/original/"); importor.Import(GetImportedDir(), ProductsData_Imported); tbxMsg.CssClass = "success"; tbxMsg.Text = importor.ImportMsg; //保存日志 bizImportlog.Import(fileNames, importor.Result_ProductsSuccessImported, finishTime, tbxFrom.Text , "数据部",importor.ImportMsgForLog); } catch (Exception ex) { tbxMsg.CssClass = "error"; tbxMsg.Text = ex.Message; if (ex.InnerException != null) { tbxMsg.Text += Environment.NewLine + ex.InnerException.Message; } } }
protected void btnImport_Click(object sender, EventArgs e) { try { string errMsg; NModel.ImportOperationLog importLog = new NModel.ImportOperationLog(); IList<NModel.Product> productImported= bizProduct.ImportProductFromExcel(fuProduct.PostedFile.InputStream,out errMsg); importLog.FileFrom = tbxSource.Text.Trim(); importLog.FinishTime = DateTime.Parse(tbxFinishTime.Text); importLog.ImportedFileName = fuProduct.FileName; importLog.ImportedItems = productImported; importLog.ImportMember = tbxOperator.Text.Trim(); importLog.ImportResult = errMsg; importLog.ImportTime = DateTime.Now; // bizLog.Save(importLog); lblMsg.Attributes["class"] = "success"; lblMsg.InnerHtml = errMsg; } catch (Exception ex){ lblMsg.Attributes["class"] = "error"; string innerException = ex.InnerException==null ?"": ex.InnerException.Message; lblMsg.InnerHtml = ex.Message+"<br/>"+innerException; } }