private void SaveAuthensToPark(List <string> records) { FrmProcessing frmP = new FrmProcessing(); Action action = delegate() { try { int success = 0; int fail = 0; FreeAuthorizationLogBll bll = new FreeAuthorizationLogBll(AppSettings.CurrentSetting.ParkConnect); foreach (string record in records) { Ralid.Park.POS.Model.FreeAuthorizationLog p = Ralid.Park.POS.Model.FreeAuthorizationLogSerializer.Deserialize(record); if (p != null) { FreeAuthorizationLog item = CreateFrom(p); CommandResult ret = bll.InsertRecordWithCheck(item); if (ret.Result == ResultCode.Successful) { success++; } else { fail++; } } else { fail++; } frmP.ShowProgress(string.Format(Resource1.FrmMain_ImportAuthenLog + " " + Resource1.FrmMain_Success + ":{0} " + Resource1.FrmMain_Fail + ":{1} " + Resource1.FrmMain_ImportTotal + ": {2}", success, fail, records.Count), (decimal)(success + fail) / records.Count); } ShowMessage(string.Format(Resource1.FrmMain_ImportAuthenLog + " " + Resource1.FrmMain_Success + ":{0} " + Resource1.FrmMain_Fail + ":{1} " + Resource1.FrmMain_ImportTotal + ": {2}", success, fail, records.Count), Color.Black); } catch (ThreadAbortException) { } catch (Exception ex) { frmP.ShowProgress(ex.Message, 1); ShowMessage(ex.Message, Color.Red); } }; Thread t = new Thread(new ThreadStart(action)); t.Start(); if (frmP.ShowDialog() != DialogResult.OK) { t.Abort(); } }
private void SavePaymentsToPark(List <string> records) { FrmProcessing frmP = new FrmProcessing(); Action action = delegate() { try { int success = 0; int fail = 0; CardPaymentRecordBll bll = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect); foreach (string record in records) { Ralid.Park.POS.Model.CardPaymentInfo p = Ralid.Park.POS.Model.CardPaymentInfoSerializer.Deserialize(record); if (p != null) { CardPaymentInfo item = CreateFrom(p); CommandResult ret = bll.InsertRecordWithCheck(item); if (ret.Result == ResultCode.Successful) { success++; } else { fail++; } } else { fail++; } frmP.ShowProgress(string.Format("数据导入状态 成功:{0} 失败:{1} 总共需导入: {2}", success, fail, records.Count), (decimal)(success + fail) / records.Count); } ShowMessage(string.Format("数据导入状态 成功:{0} 失败:{1} 总共需导入: {2}", success, fail, records.Count), Color.Black); } catch (ThreadAbortException) { } catch (Exception ex) { frmP.ShowProgress(ex.Message, 1); ShowMessage(ex.Message, Color.Red); } }; Thread t = new Thread(new ThreadStart(action)); t.Start(); if (frmP.ShowDialog() != DialogResult.OK) { t.Abort(); } }