protected void Execute(DataTable dt, FileInfo NextFile) { if (dt.Rows.Count == 0) { LogInfo.Log.Info(NextFile.FullName + "为空文件"); FileMove(NextFile, folderPath_Success); return; } try { if (dt.PrimaryKey.Count() != 1) { MSSQLFactory.BulkCopy(context.connStr, dt); //文件移动 FileMove(NextFile, folderPath_Success); LogInfo.Log.Info("处理文件:【" + NextFile.FullName + "】成功"); } else { //文件移动 FileMove(NextFile, folderPath_Faild); LogInfo.Log.Info("处理文件:【" + NextFile.FullName + "】失败,主键有" + dt.PrimaryKey.Count() + "个"); } } catch (Exception ex) { LogInfo.Log.Info("处理文件:【" + NextFile.FullName + "】失败,详细见错误日志"); LogInfo.Log.Error(ex); FileMove(NextFile, folderPath_Faild); //发送邮件并移至错误文件夹中 context.MessageQueue("SAP联携异常", NextFile.FullName + "文件处理异常:" + ex.Message); } }
static void Main(string[] args) { try { MSSQLFactory mSSQLFactory = new MSSQLFactory(); mSSQLFactory.AddConnection("", "", 10, 10, 10); mSSQLFactory.BuildMethod(); mSSQLFactory.Method_DataTable(); } catch (Exception ex) { throw ex; } }