public void DoTransfer() { int handle = 0; Global.BCCInit(); //make a new bcc handle handle = BCCHelper.NewXpackHandle(@"KSLib\cpack.dat"); importedAmount = 0.0d; importedCnt = 0; errors = new List <string>(); DateTime start = DateTime.Now; foreach (DataRow dr in dataSource.Rows) { BCCHelper.ResetPackHandle(handle); DoSingleEntryTrans(dr, handle); } AllEntryCompletedEventArgs e = new AllEntryCompletedEventArgs(dataSource.Rows.Count, "All Completed!"); StringBuilder summary = new StringBuilder(); summary.Append(System.Environment.NewLine + "结果汇总:" + System.Environment.NewLine); summary.Append("\t原始记录数:" + dataSource.Rows.Count + System.Environment.NewLine); summary.Append("\t导入开始时间:" + start.ToString() + System.Environment.NewLine); summary.Append("\t导入结束时间:" + DateTime.Now.ToString() + System.Environment.NewLine); summary.AppendFormat("\t成功处理:{0}条,总金额:{1} {2}", importedCnt, importedAmount, System.Environment.NewLine); summary.Append("\t未能导入的名单如下:" + System.Environment.NewLine); summary.AppendFormat("{0}", FormatListToString(errors)); e.Errors = errors; e.Summary = summary.ToString(); OnAllEntryCompleted(e); }
private void PrepareRelations() { if (dtRelation == null) { dtRelation = new DataTable("relations"); dtRelation.Columns.Add("StaffId", typeof(string)); dtRelation.Columns.Add("Name", typeof(string)); dtRelation.Columns.Add("WalletId", typeof(string)); dtRelation.PrimaryKey = new DataColumn[] { dtRelation.Columns[0] }; } dtRelation.Rows.Clear(); int handle = 0; Global.BCCInit(); //make a new bcc handle handle = BCCHelper.NewXpackHandle(@"KSLib\cpack.dat"); if (BCCHelper.SetRequestType(handle, 841601)) { int errCode = 0; int retCode = -1; bool hasMorePack = false; StringBuilder errMsg = new StringBuilder(255); bool requestStatus = BCCHelper.CallRequest(handle, Global.Drtp_NO, Global.Drtp_Branch, Global.BCC_BaseFunction, 5000, ref errCode, errMsg); if (!requestStatus) { Global.Logger.Warn(string.Format("BCCHelper.CallRequest[841601] failed! errorCode ={0} and errMsg= {1}", errCode, errMsg)); return; } BCCHelper.GetRetCode(handle, ref retCode); //int packageCnt = 0; do { if (retCode != 0) { continue; } //show data rows of package into grid view int cnt = 0; BCCHelper.GetRecordCount(handle, ref cnt); for (int rowIndex = 0; rowIndex < cnt; rowIndex++) { DataRow dr = dtRelation.NewRow(); dr["StaffId"] = BCCHelper.GetStringFieldByName(handle, rowIndex, "scust_auth2"); dr["Name"] = BCCHelper.GetStringFieldByName(handle, rowIndex, "sname"); dr["WalletId"] = BCCHelper.GetStringFieldByName(handle, rowIndex, "sname2"); dtRelation.Rows.Add(dr); } } while (hasMorePack = BCCHelper.HaveNextPack(handle) && BCCHelper.CallNext(handle, 5000, ref errCode, errMsg)); } else { Global.Logger.Info("BCCHelper.SetRequestType[841601] failed!"); } //release cpack handle if (handle != 0) { BCCHelper.DeleteXpackHandle(handle); Global.Logger.Info("delete xpack handle for request type= 841601"); } }