public TransResult <T> Update(T updated) { TransResult <T> result = new TransResult <T>() { IsSuccess = true }; if (updated == null) { return(new TransResult <T>() { IsSuccess = false });; } try { _context.Set <T>().Attach(updated); _context.Entry(updated).State = EntityState.Modified; _context.SaveChanges(); } catch (Exception ex) { result.IsSuccess = false; } return(result); }
//private YAEntity _entity = null; protected override void OnEnter() { DestroySelf(); //设置成自动销毁,每次重新生成 //_entity = GetBusinessEntity() as YAEntity; TransResult res = TransResult.E_RECV_FAIL; CYATrafficInquiry inquiry = new CYATrafficInquiry(); res = SyncTransaction(inquiry); if (res == TransResult.E_SUCC) { StartActivity("雅安交警认罚信息"); } else if (res == TransResult.E_HOST_FAIL) { ShowMessageAndGotoMain(inquiry.ReturnCode + "-" + inquiry.ReturnMessage); } else if (res == TransResult.E_RECV_FAIL) { ShowMessageAndGotoMain("交易超时,请重试"); } else { ShowMessageAndGotoMain("交易失败,请重试"); } }
protected override void OnEnter() { CPetroPayUserInfoQuery infoQuery = new CPetroPayUserInfoQuery(); TransResult ret = SyncTransaction(infoQuery); if (ret == TransResult.E_SUCC) { StartActivity("中石油支付用户信息显示"); } else if (ret == TransResult.E_HOST_FAIL) { if (infoQuery.ReturnCode == "D3") { ShowMessageAndGotoMain("验证密码失败!请提供正确用户名及密码!"); } else { ShowMessageAndGotoMain(infoQuery.ReturnCode + "-" + infoQuery.ReturnMessage); } } else if (ret == TransResult.E_RECV_FAIL) { ShowMessageAndGotoMain("交易超时,请重试"); } else { ShowMessageAndGotoMain("交易失败,请重试"); } }
protected TransResult CADown() { TransResult eRet = TransResult.E_SUCC; foreach (CaItem item in m_caList) { System.Threading.Thread.Sleep(2000);//四川版每个交易之间要停顿2S int nLen = item.cRid.Length + item.cIndex.Length; m_downCA = new byte[nLen]; Array.Copy(item.cRid, m_downCA, item.cRid.Length); //RID Array.Copy(item.cIndex, 0, m_downCA, item.cRid.Length, item.cIndex.Length); //索引 eRet = Communicate(); if (eRet != TransResult.E_SUCC) { break; } Array.Copy(m_downCAItem, 0, m_downCAAll, m_nAllCA, m_downCAItem.Length); m_nAllCA += m_downCAItem.Length; } return(eRet); }
public static bool ICDownAID(List <byte[]> aidItemList) { bool result = false; byte[] bAllAID = new byte[1024 * 4]; int nAllAID = 0; TransResult eRet = TransResult.E_SUCC; foreach (byte[] item in aidItemList) { CDownAID dAID = new CDownAID(); dAID.BField62 = new byte[item.Length]; Array.Copy(item, dAID.BField62, item.Length); eRet = dAID.Communicate(); if (eRet != TransResult.E_SUCC) { break; } Array.Copy(dAID.BAID, 0, bAllAID, nAllAID, dAID.BAID.Length); nAllAID += dAID.BAID.Length; } Log.Warn("IC卡下载IC卡参数CDownAID:Ret=" + eRet.ToString()); if (eRet == TransResult.E_SUCC) { Log.Info("IC卡AID下载参数成功"); string caPath = Path.Combine(StartupPath, "pbocaid.txt"); result = CreateFile(caPath, bAllAID, nAllAID); } return(result); }
protected override void OnEnter() { CYATrafficPoliceBillQuery infoQuery = new CYATrafficPoliceBillQuery(); TransResult ret = SyncTransaction(infoQuery); if (ret == TransResult.E_SUCC) { StartActivity("雅安交警罚没违章显示"); } else if (ret == TransResult.E_HOST_FAIL) { if (infoQuery.ReturnCode == "D3") { ShowMessageAndGotoMain("验证密码失败!请提供正确决定书编号!"); } else { ShowMessageAndGotoMain(infoQuery.ReturnCode + "-" + infoQuery.ReturnMessage); } } else if (ret == TransResult.E_RECV_FAIL) { ShowMessageAndGotoMain("交易超时,请重试"); } else { ShowMessageAndGotoMain("交易失败,请重试"); } }
public TransactionResult(TransResult result, string message, object returnObject, int?id = null) { Result = result; Message = message; ReturnObject = returnObject; Id = id; }
protected override void OnEnter() { CPetroModifyPassProcess PetroModifyPassProcess = new CPetroModifyPassProcess(); TransResult ret = SyncTransaction(PetroModifyPassProcess); if (ret == TransResult.E_SUCC) { StartActivity("中石油修改密码成功"); } else if (ret == TransResult.E_HOST_FAIL) { if (PetroModifyPassProcess.ReturnCode == "D3") { ShowMessageAndGoBack("验证密码失败!请提供正确用户名及密码!"); } else { ShowMessageAndGoBack(PetroModifyPassProcess.ReturnCode + "-" + PetroModifyPassProcess.ReturnMessage); } } else if (ret == TransResult.E_RECV_FAIL) { ShowMessageAndGoBack("交易超时,请重试"); } else { ShowMessageAndGoBack("交易失败,请重试"); } }
private int QueryMsgDeal() { QueryPay query = new QueryPay(); TransResult result = SyncTransaction(query); if (result == TransResult.E_SUCC) { if (string.Compare(entity.cardinfo.cardType, "1") == 0) { try { Log.Info("entity.Amount : " + entity.Amount); #if DEBUG entity.Amount = "1"; #endif CommonData.Amount = double.Parse(entity.Amount.TrimStart('0')); } catch (Exception ex) { ShowMessageAndGotoMain("查询失败|返回金额格式出错"); return(-1); } } return(0); } else { ShowMessageAndGotoMain("查询失败|"); } return(-1); }
private void ReWrite() { CPowerCardWriteAgain writeAgain = new CPowerCardWriteAgain(); _transResult = writeAgain.WritePowerCardAgain(); Log.Debug("补写卡交易返回:" + writeAgain.ReturnCode); }
public TransResult TransExecute() { while (IsTransDoing()) { System.Threading.Thread.Sleep(500); } UpdateTransDoing(true); TransResult nRet = TransResult.E_SEND_FAIL; if (!GPRSConnect()) { UpdateTransDoing(false); return(nRet); } //冲正 CReverse rev = new CReverse(); rev.DoLastReverse(); //交易 nRet = Trans(); UpdateTransDoing(false); return(nRet); }
protected TransResult ParamEnd() { TransResult eRet = TransResult.E_SUCC; eRet = Communicate(); return(eRet); }
public async Task <TransResult <T> > UpdateAsync(T updated) { TransResult <T> result = new TransResult <T>() { IsSuccess = true }; if (updated == null) { return(new TransResult <T>() { IsSuccess = false });; } try { _context.Set <T>().Attach(updated); _context.Entry(updated).State = EntityState.Modified; await _unitOfWork.Commit(); } catch (Exception ex) { result.IsSuccess = false; } return(result); }
protected virtual TransResult Trans() { TransResult nRet = TransResult.E_SEND_FAIL; try { PackFix(); Packet(); nRet = Communicate(); AppLog.Write("[" + this.GetType().Name + "][Trans]nRet = " + Convert.ToString(nRet), AppLog.LogMessageType.Info, this.GetType()); if (nRet == TransResult.E_HOST_FAIL || nRet == TransResult.E_SUCC) { UnpackFix(); } if (nRet == TransResult.E_SUCC) { if (!UnPacket()) { nRet = TransResult.E_UNPACKET_FAIL; } } } catch (Exception err) { AppLog.Write("[" + this.GetType().Name + "][Trans]Error!\n", AppLog.LogMessageType.Error, err, this.GetType()); } return(nRet); }
/// <summary> /// 同步下载IC卡AID入口 /// </summary> /// <returns></returns> public static bool ICAIDEntry() { //Log.Info("========开始下载IC卡参数========"); TransResult eRet = TransResult.E_SUCC; bool bResult = false; byte bContinue = 0x30; List <byte[]> aidItemList = new List <byte[]>(); CQueryAID qaid = new CQueryAID(); eRet = qaid.Communicate(); if (eRet == TransResult.E_SUCC) { bResult = true; aidItemList.AddRange(qaid.AIDItemList); bContinue = qaid.BField62; if (bContinue == 0x32) { while (eRet == TransResult.E_SUCC && bContinue == 0x32) { System.Threading.Thread.Sleep(2000);//四川版需要停顿 CQueryAID qaid2 = new CQueryAID(); qaid2.StrField62 = "1" + aidItemList.Count.ToString().PadLeft(2, '0'); eRet = qaid2.Communicate(); if (eRet == TransResult.E_SUCC) { aidItemList.AddRange(qaid2.AIDItemList); bContinue = qaid2.BField62; } else { bResult = false; } } } if (bResult && aidItemList.Count > 0) { System.Threading.Thread.Sleep(2000);//四川版需要停顿 bResult = CDownAID.ICDownAID(aidItemList); if (bResult) { CEndAID eaid = new CEndAID(); eaid.Communicate(); } //string caPath = Path.Combine(StartupPath, "pbocaid.txt"); //byte[] bAllAID = new byte[1024 * 4]; //int nAllAID = 0; //foreach (byte[] item in aidItemList) //{ // Array.Copy(item, 0, bAllAID, nAllAID, item.Length); // nAllAID += item.Length; //} //bResult = CreateFile(caPath, bAllAID, nAllAID); } } Log.Warn("IC卡下载IC卡参数CQueryAID:Ret=" + eRet.ToString()); //Log.Info("========结束下载IC卡参数========"); return(bResult); }
private void BeingProcess(object sender, DoWorkEventArgs e) { cSPospTrans = new CSPospTrans(_entity); cSPospTrans.setIPAndPort(_entity.CspospServerIP, _entity.CspospServerPort); result = cSPospTrans.transact(); return; }
internal void TransactionCompleted(PackageBase.ResultHandler handler, TransResult ret) { Activity.TransactionCompleted(ret); if (handler != null) { handler(ret); } }
internal static void TransactionCompleted(TransResult transResult) { lock (mLock) { LastTransResult = transResult; mTransCompleted = true; } }
protected TransResult ParamDown() { TransResult eRet = TransResult.E_SUCC; System.Threading.Thread.Sleep(2000);//四川版每个交易之间要停顿2S eRet = Communicate(); return(eRet); }
private void PayResult(TransResult retPay) { if (retPay == TransResult.E_SUCC) { //缴费成功,发起确认销账 CPetroPayBillConfirm billConfirm = new CPetroPayBillConfirm(); TransResult retConfirm = SyncTransaction(billConfirm); if (retConfirm != TransResult.E_SUCC) { CReverse_PetroChinaPay rev = new CReverse_PetroChinaPay(PetroPayBeingPay); rev.Reason = "06"; rev.Field55 = emv.EMVInfo.AutoField55; SyncTransaction(rev); ShowMessageAndGotoMain("交易超时,请重试"); } else { if (ReceiptPrinter.ExistError()) { StartActivity("中石油支付交易完成"); } else { StartActivity("中石油支付交易成功是否打印"); } } } else if (retPay == TransResult.E_HOST_FAIL) { if (PetroPayBeingPay.ReturnCode == "51") { ShowMessageAndGotoMain("温馨提示:抱歉!交易失败!" + "\n" + "您卡内余额不足!"); } else if (PetroPayBeingPay.ReturnCode == "55") { StartActivity("中石油支付密码错误"); } else { ShowMessageAndGotoMain(PetroPayBeingPay.ReturnCode + "-" + PetroPayBeingPay.ReturnMessage); } } else if (retPay == TransResult.E_RECV_FAIL) { CReverse_PetroChinaPay rev = new CReverse_PetroChinaPay(PetroPayBeingPay); rev.Reason = "98"; rev.Field55 = emv.EMVInfo.AutoField55; SyncTransaction(rev); ShowMessageAndGotoMain("交易超时,请重试"); } else { ShowMessageAndGotoMain("交易失败,请重试"); } }
private int QueryMsgDeal() { ProtoQuery query = new ProtoQuery(); TransResult result = SyncTransaction(query); if (result == TransResult.E_SUCC) { return(0); } return(-1); }
private TransResult ConfirmBillProcess() { TransResult retConfirm = TransResult.E_RECV_FAIL; PostAsync(billcheck); if (retConfirm != TransResult.E_SUCC && retConfirm != TransResult.E_RECV_FAIL) { ShowMessageAndGotoMain(billConfirm.ReturnCode + "-" + billConfirm.ReturnMessage); } return retConfirm; }
private void billcheck() { try { retConfirm = billConfirm.BillCheck(); } catch (Exception ex) { Log.Debug("bullcheck err:", ex); } }
public static bool ICDownPublicCA(List <CaItem> caItemList) { bool result = false; if (caItemList.Count > 0) { byte[] bAllCA = new byte[1024 * 4]; int nAllCA = 0; TransResult eRet = TransResult.E_SUCC; foreach (CaItem item in caItemList) { byte[] rid = new byte[item.cRid.Length + 3]; rid[0] = 0x9F; rid[1] = 0x06; rid[2] = (byte)item.cRid.Length; Array.Copy(item.cRid, 0, rid, 3, item.cRid.Length); byte[] index = new byte[item.cIndex.Length + 3]; index[0] = 0x9F; index[1] = 0x22; index[2] = (byte)item.cIndex.Length; Array.Copy(item.cIndex, 0, index, 3, item.cIndex.Length); CDownPublicCA dCA = new CDownPublicCA(); dCA.BField62 = new byte[rid.Length + index.Length]; Array.Copy(rid, dCA.BField62, rid.Length); Array.Copy(index, 0, dCA.BField62, rid.Length, index.Length); eRet = dCA.Communicate(); //Test //eRet = TransResult.E_SUCC; //string s = "9F0605A0000000039F220172DF05083230313030313031DF060101DF070101DF028190BD9F074D8F60501D2E87B3AB03DCA80C83AF9CE81372AD34B7FA639767E5E6B2491ADCAF943FA165D09AB25B4B8FF541E6D2D3B0B70705B105266751D27E8E56FD9D0974F67B3B2E84322DA7E56152A4E42CC63727EB160B2E5310DF125E74F55618FE8727B167B6456431CFDE80C025D0CB1DE7DDC3186B7314085C7CCA301C691F5577690FD2DE5FC62665CB163F0DDF0403010001DF03141ECF2EFE0B01FA7C94F3960056E748C8FF4F1D09"; //dCA.BCA = Utility.str2Bcd(s); if (eRet != TransResult.E_SUCC) { break; } Array.Copy(dCA.BCA, 0, bAllCA, nAllCA, dCA.BCA.Length); nAllCA += dCA.BCA.Length; System.Threading.Thread.Sleep(2000);//四川版需要停顿 } Log.Warn("IC卡公钥下载参数CDownPublicCA:Ret=" + eRet.ToString()); if (eRet == TransResult.E_SUCC) { Log.Info("IC卡公钥下载参数成功"); string caPath = Path.Combine(StartupPath, "pbocCA.txt"); result = CreateFile(caPath, bAllCA, nAllCA); } } return(result); }
protected TransResult AIDQuery() { m_aidList.Clear(); TransResult eRet = TransResult.E_SUCC; do { System.Threading.Thread.Sleep(2000);//四川版每个交易之间要停顿2S eRet = Communicate(); } while (eRet == TransResult.E_SUCC && m_bContinue == 0x32); return(eRet); }
private void Inquery() { try { infoQuery = new CPowerCardBillQuery(); ret = infoQuery.BillQuery(); } catch (Exception ex) { Log.Error("inquery error:", ex); } }
private void querymsg(object sender, DoWorkEventArgs e) { try { CRLQueryTrans cSPospTrans = new CRLQueryTrans(_entity); cSPospTrans.setIPAndPort(_entity.RLServerIP, _entity.RLServerPort); result = cSPospTrans.transact(); } catch (Exception ex) { Log.Error("[" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "][" + System.Reflection.MethodBase.GetCurrentMethod().Name + "] err" + ex); } return; }
protected override void OnEnter() { #if DEBUG CommonData.Amount = 195.5; #endif CPetroPayBillQuery PetroPayBillQuery = new CPetroPayBillQuery(); TransResult ret = SyncTransaction(PetroPayBillQuery); if (ret == TransResult.E_SUCC) { YAPaymentPay.ListQueryInfo.Clear(); int nQueryCount = 0; int.TryParse(YAPaymentPay.QueryCount, out nQueryCount); if (nQueryCount != 0) { YAPaymentPay.ListQueryInfo.AddRange(YAPaymentPay.QueryContent.Split(';')); } if (YAPaymentPay.ListQueryInfo.Count != nQueryCount) { Log.Warn("缴费账单查询的条数不一致"); ShowMessageAndGoBack("查询失败"); } else { StartActivity("中石油支付账单费用显示"); } } else if (ret == TransResult.E_HOST_FAIL) { if (PetroPayBillQuery.ReturnCode == "D3") { ShowMessageAndGoBack("该账户已经缴费,无缴费记录");//该账户无欠费记录 } else { ShowMessageAndGoBack(PetroPayBillQuery.ReturnCode + "-" + PetroPayBillQuery.ReturnMessage); } } else if (ret == TransResult.E_RECV_FAIL) { ShowMessageAndGotoMain("交易超时,请重试"); } else { ShowMessageAndGotoMain("交易失败,请重试"); } }
TransResult EMV_ISO8583Trans() { CommonData.BankCardNum = emv.EMVInfo.CardNum; CommonData.BankCardSeqNum = emv.EMVInfo.CardSeqNum; CommonData.BankCardExpDate = emv.EMVInfo.CardExpDate; CommonData.Track2 = emv.EMVInfo.Track2; PetroChinaPay.SendField55 = emv.EMVInfo.SendField55; TransResult ret = PetroPayBeingPay.Communicate(); if (ret == TransResult.E_SUCC) { emv.EMVInfo.RecvField55 = PetroChinaPay.RecvField55; emv.EMVInfo.RecvField38 = PetroChinaPay.RecvField38; } return(ret); }
protected override void OnEnter() { base.OnEnter(); try { _entity = GetBusinessEntity() as RLCZEntity; result = TransResult.E_INVALID; BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += querymsg; bw.RunWorkerAsync(); bw.RunWorkerCompleted += bw_RunWorkerCompleted; } catch (Exception ex) { Log.Error("[" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "][" + System.Reflection.MethodBase.GetCurrentMethod().Name + "] err" + ex); } }