using System.Windows;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
using Muchinfo.MTPClient.Bank.Views;
using Muchinfo.MTPClient.CustomException;
using Muchinfo.MTPClient.Data;
using Muchinfo.MTPClient.Data.Enums;
using Muchinfo.MTPClient.Data.Extensions;
using Muchinfo.MTPClient.Data.Model.Account;
using Muchinfo.MTPClient.Data.Model.Bank;
using Muchinfo.MTPClient.Infrastructure.Helpers;
using Muchinfo.MTPClient.Infrastructure.MessageBox;
using Muchinfo.MTPClient.Infrastructure.Utilities;
using Muchinfo.MTPClient.IService;
using Muchinfo.PC.Common.Extensions;
using Muchinfo.PC.Common.Helpers;
using Muchinfo.WPF.Controls.Windows;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
namespace Muchinfo.MTPClient.Bank.ViewModels
{
public class BankUpdateViewModel : IdentifyCodeTimerViewModel
{
#region 变量成员
private IBankService _bankService;
private BankUpdateView _view;
private EncryptKey _encryptKey;
private AreaAccount _areaAccount; //会员账号信息
private bool _isBusy;
///
/// 是否忙,显示等待控件
///
public bool IsBusy
{
get { return _isBusy; }
set { Set(() => IsBusy, ref _isBusy, value); }
}
private string _busyContent;
public string BusyContent
{
get { return _busyContent; }
set { Set(() => BusyContent, ref _busyContent, value); }
}
///
///证件类型
///
public Dictionary ClientCardTypes
{
get
{
//var types = new Dictionary { { ClientCardType.Id, ClientCardType.Id.Discription() }, { ClientCardType.Driver, ClientCardType.Driver.Discription() } };
//return types;
return EnumExtensions.ToDictionary();
}
}
#region 确认银行账号
private string _BankAccountConfirm = string.Empty;
///
/// 确认银行账号
///
public string BankAccountConfirm
{
get
{
return _BankAccountConfirm;
}
set
{
Set(() => BankAccountConfirm, ref _BankAccountConfirm, value);
}
}
#endregion
///
/// 银行列表数据源
///
private List BankListSource=new List();
private ObservableCollection _bankList;
///
/// 开户银行列表
///
/// The bank branch dictionary.
public ObservableCollection BankList
{
get
{
return _bankList;
}
set
{
Set(() => BankList, ref _bankList, value);
}
}
private Banks _selectBankItem;
///
/// 选择银行
///
public Banks SelectBankItem
{
get
{
return _selectBankItem;
}
set
{
Set(() => SelectBankItem, ref _selectBankItem, value);
if (value != null)
{
CurrentSigningBank.BankId = value.BankId;
CurrentSigningBank.Name = value.BankName;
}
}
}
//private List _cusBankList = new List();
/////
///// 签约的托管银行
/////
//public List CusBankList
//{
// get { return _cusBankList; }
// set { Set(() => CusBankList, ref _cusBankList, value); }
//}
//private SigningBank _currentCusBank;
/////
///// 当前选中的托管银行
/////
//public SigningBank CurrentCusBank
//{
// get { return _currentCusBank; }
// set
// {
// Set(() => CurrentCusBank, ref _currentCusBank, value);
// if (value != null)
// {
// CurrentSigningBank = SignBankList.FirstOrDefault(m => m.CusBankID == value.CusBankID);
// }
// }
//}
private ObservableCollection _signBankList;
///
/// 客户签约银行列表
///
public ObservableCollection SignBankList
{
get { return _signBankList; }
set { Set(() => SignBankList, ref _signBankList, value); }
}
private List _cusBankInfo;
///
/// 托管银行信息
///
public List CusBankInfo
{
get { return _cusBankInfo; }
set { _cusBankInfo = value; }
}
#region 变更后银行信息
private SigningBank _newSigningBank = new SigningBank();
///
/// Sets and gets the NewSigningBank property.
///
public SigningBank NewSigningBank
{
get
{
return _newSigningBank;
}
set
{
Set(() => NewSigningBank, ref _newSigningBank, value);
}
}
#endregion
private SigningBank _currentSigningBank;
///
/// 当前选中签约银行
///
public SigningBank CurrentSigningBank
{
get
{
return _currentSigningBank;
}
set
{
Set(() => CurrentSigningBank, ref _currentSigningBank, value);
//银行Id获取银行支行列表
//Dictionary BankBranchDictionary = _bankService.GetBankBranchList(value.Id);
//支行Id获取支行名称
//BranchName = BankBranchDictionary[value.BranchId];
CredentialTypeName = ClientCardTypes[value.CredentialType];
SetCollapsed();
SetSignBankInfo();
}
}
private string _credentialTypeName;
///
/// 开户人证件类型名称
///
public string CredentialTypeName
{
get
{
return _credentialTypeName;
}
set
{
Set(() => CredentialTypeName, ref _credentialTypeName, value);
}
}
private string _branchName;
///
/// 开户银行支行名称
///
public string BranchName
{
get
{
return _branchName;
}
set
{
Set(() => BranchName, ref _branchName, value);
}
}
///
/// 建行三方提示
///
private bool _branchMessage = false;
///
/// 建行三方提示
///
public bool BranchMessage
{
get
{
return _branchMessage;
}
set
{
Set(() => BranchMessage, ref _branchMessage, value);
}
}
///
/// 网银签约解约提示
///
private bool _netMessage = false;
///
/// 网银签约解约提示
///
public bool NetMessage
{
get
{
return _netMessage;
}
set
{
Set(() => NetMessage, ref _netMessage, value);
}
}
private string _netWorkSignTips;
///
/// 网银端提示
///
public string NetWorkSignTips
{
get { return _netWorkSignTips; }
set
{
Set(() => NetWorkSignTips, ref _netWorkSignTips, value);
}
}
///
/// 是否可点确定
///
private bool _isOKEnable = true;
///
/// 是否可点确定
///
public bool IsOKEnable
{
get
{
return _isOKEnable;
}
set
{
Set(() => IsOKEnable, ref _isOKEnable, value);
}
}
///
///银行列表
///
List AccoumtBankSignList;
#endregion
#region 构造函数
public BankUpdateViewModel(BankUpdateView view)
{
_view = view;
IsBusy = true;
temp_ankDealStatus = null;
BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfo_Waiting;
_bankService = SimpleIoc.Default.GetInstance();
// _bankService.QueryBankInfo(QueryBankInfoCallback, ErrorCallback);
//todo: QueryBankCustomerSign 未返回CusBankName 先查询QueryCusBankInfo返回匹配该字段
// SignBankList =
//_bankService.QueryBankCustomerSign(QueryBankCustomerSignCallback, ErrorCallback);
var accountid = UserManager.CurrentTradeAccount.AccountId;
//if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
//{
// accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
//}
_bankService.QueryBankCustomerSignInfo(accountid, SearchBankCustomerSignCallback, ErrorCallback);
}
///
/// 查询签约信息回应
///
///
private void SearchBankCustomerSignCallback(List list)
{
IsBusy = false;
if (ApplicationParameter.NewBankPlatform == 1) ////新银行平台
{
SignBankList = new ObservableCollection(list);
}
else
{
SignBankList = new ObservableCollection(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType == SignStatus.SignStatus_Signed));
}
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
if (SignBankList == null || SignBankList.Count <= 0)
{
MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
// BankUpdateView.Close();
_view.Close();
return;
}
CurrentSigningBank = SignBankList.FirstOrDefault();
BankAccountConfirm = CurrentSigningBank.BankAccount;
}));
}
private void QueryBankCustomerSignCallback(ObservableCollection list)
{
IsBusy = false;
SignBankList = new ObservableCollection(list.Where((item) => item.ShowCancelSign == 0 && item.SignStatusType==SignStatus.SignStatus_Signed));
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
if (SignBankList == null || SignBankList.Count <= 0)
{
MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoSignWithBank, Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
// BankUpdateView.Close();
_view.Close();
return;
}
if (null != AccoumtBankSignList && AccoumtBankSignList.Any())
{
foreach (var item in SignBankList)
{
foreach (var k in AccoumtBankSignList)
{
if (item.BankId == k.BankId)
{
item.Name = k.BankName;
// item.AccountName = UserManager.CurrentTradeAccount.CustomerName;
}
if (item.BranchId == k.BankId)
{
item.BranchBankName = k.BankName;
}
}
}
}
CurrentSigningBank = SignBankList.FirstOrDefault();
}));
}
#endregion
public RelayCommand OkCommand
{
get
{
return new RelayCommand((win_BankUpdateView) =>
{
if (CurrentSigningBank == null)
{
return;
}
if (Validate())
{
IsBusy = true;
BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_SubmitChangeBankInfo_Wait;
this.NewSigningBank.CusBankID = CurrentSigningBank.CusBankID;
this.NewSigningBank.CustomerSignId = CurrentSigningBank.CustomerSignId;
this.NewSigningBank.AccountName = CurrentSigningBank.AccountName;
this.NewSigningBank.BankAccount = CurrentSigningBank.BankAccount;
this.NewSigningBank.BankId = CurrentSigningBank.BankId;
this.NewSigningBank.Name = CurrentSigningBank.Name;
if (CurrentSigningBank.MobilePhone!="")
this.NewSigningBank.MobilePhone = CurrentSigningBank.MobilePhone;
NewSigningBank.ExtOperatorID = UserManager.CurrentTradeAccount.AccountId;
NewSigningBank.AccountType = UserManager.CurrentTradeAccount.AccountType;
NewSigningBank.AccountCode = UserManager.CurrentTradeAccount.AccountCode;
_bankService.SignUpdate(NewSigningBank, SignUpdateCallback, ErrorCallback);
}
});
}
}
///
/// 验证
///
/// 是否通过
private bool Validate()
{
if (string.IsNullOrEmpty(CurrentSigningBank.BankAccount))
{
MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankAccount, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
return false;
}
if (string.IsNullOrEmpty(this.BankAccountConfirm))
{
MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ConfirmBankAccount, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
return false;
}
if (this.CurrentSigningBank.BankAccount.Trim() != BankAccountConfirm)
{
MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_InputBankAccountDifferent, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
return false;
}
//if (this.NewBankAccount.Trim() == this.BankAccount.Trim())
//{
// MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NewAndOldAccountSame, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
// return false;
//}
return true;
}
///
/// 取消
///
public RelayCommand CancelCommand
{
get
{
temp_ankDealStatus = null;
return new RelayCommand((win_BankUpdateView) =>
{
win_BankUpdateView.Close();
});
}
}
private void SignUpdateCallback(int result)
{
IsBusy = false;
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
if (result == 0)
{
MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ChangeBankInfoSuccess_Wait, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
_view.Close();
}
else
{
ErrorManager.ShowReturnError(result, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
}
}));
}
private void SetCollapsed()
{
this.CurrentSigningBank.PaymentNumberVisibility = false;
this.CurrentSigningBank.ProtocolNumberVisibility = false;
this.CurrentSigningBank.MobilePhoneVisibility = false;
//this.CurrentSigningBank.CertIDVisibility = false;
//this.CurrentSigningBank.BankVisibility = false;
//this.CurrentSigningBank.BranchVisibility = false;
//this.CurrentSigningBank.BankBankAccountNoVisibility = false;
//this.CurrentSigningBank.AccountNameVisibility = false;
this.CurrentSigningBank.AgentNameVisibility = false;
this.CurrentSigningBank.AgentCIDNumberVisibility = false;
this.CurrentSigningBank.BankPasswordVisibility = false;
this.CurrentSigningBank.DrawIdentifyCodeVisibility = false;
if (!string.IsNullOrEmpty(CurrentSigningBank.ShowField))
{
bool isMemberTrade = UserManager.CurrentTradeAccount.AccountType !=
eUserType.USERTYPE_INVESTOR;
//根据当前所选签约银行,配置输入字段
string[] SignShowField = this.CurrentSigningBank.ShowField.Split(',');
foreach (string item in SignShowField)
{
switch (int.Parse(item))
{
case (int)ShowFieldStatus.ShowField_PaymentNo:
this.CurrentSigningBank.PaymentNumberVisibility = true;
break;
case (int)ShowFieldStatus.ShowField_ProtocolNo:
this.CurrentSigningBank.ProtocolNumberVisibility = true;
break;
//case (int)ShowFieldStatus.ShowField_CertID:
// this.CurrentSigningBank.CertIDVisibility = Visibility.Visible;
// break;
//case (int)ShowFieldStatus.ShowField_Bank:
// this.CurrentSigningBank.BankVisibility = Visibility.Visible;
// break;
//case (int)ShowFieldStatus.ShowField_BranchBank:
// this.CurrentSigningBank.BranchVisibility = Visibility.Visible;
// break;
//case (int)ShowFieldStatus.ShowField_BankAccountNo:
// this.CurrentSigningBank.BankBankAccountNoVisibility = Visibility.Visible;
// break;
//case (int)ShowFieldStatus.ShowField_AccountName:
// this.CurrentSigningBank.AccountNameVisibility = Visibility.Visible;
// break;
case (int)ShowFieldStatus.ShowField_AgentCertID:
this.CurrentSigningBank.AgentCIDNumberVisibility = isMemberTrade;
break;
case (int)ShowFieldStatus.ShowField_AgentName:
this.CurrentSigningBank.AgentNameVisibility = isMemberTrade;
break;
case (int)ShowFieldStatus.ShowField_BankAccountPWD:
this.CurrentSigningBank.BankPasswordVisibility = true;
//todo获取银行密钥
if (_encryptKey == null)
{
Task.Factory.TryStartNew(() =>
{
IsBusy = true;
var reqkey = new EncryptKeyRequest()
{
Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
CusBankId = CurrentSigningBank.CusBankID+string.Empty
};
// _encryptKey =
_bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback_ShowField_BankAccountPWD, ErrorCallback);
}, () => IsBusy = false);
}
break;
case (int)ShowFieldStatus.ShowField_Draw_IdentifyCode:
this.CurrentSigningBank.DrawIdentifyCodeVisibility = true;
//todo获取银行密钥
if (_encryptKey == null)
{
Task.Factory.TryStartNew(() =>
{
IsBusy = true;
var reqkeyIC = new EncryptKeyRequest()
{
Currency = (UserManager.CurrentTradeAccount.FundsAccounts == null || !UserManager.CurrentTradeAccount.FundsAccounts.Any())
? "RMB" : UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
CusBankId = CurrentSigningBank.CusBankID+string.Empty
};
//_encryptKey =
_bankService.QueryEncryptKey(reqkeyIC, QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode, ErrorCallback);
}, () => IsBusy = false);
}
break;
//case (int)ShowFieldStatus.ShowField_MobilePhone:
// this.CurrentSigningBank.MobilePhoneVisibility = true;
// break;
}
}
}
var BandIDList = ApplicationParameter.CusBankNetSign.Split(',');
if (CurrentSigningBank.CusBankID == 2 )
{
this.BranchMessage = true;
IsOKEnable = false;
}
else if (BandIDList.Contains(CurrentSigningBank.CusBankID + string.Empty))
{
this.NetMessage = true;
this.NetWorkSignTips = ApplicationParameter.CusBankNetSignTipsInfo;
IsOKEnable = false;
}
else
{
// this.BranchMessage = true;
IsOKEnable = true;
}
}
private void SetSignBankInfo()
{
IsBusy = true;
BusyContent = Muchinfo.MTPClient.Resources.Client_Resource.Bank_GetBankInfomation_waiting;
System.Threading.Tasks.Task.Factory.TryStartNew(
() => System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
var accountid = UserManager.CurrentTradeAccount.AccountId;
//if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
//{
// accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
//}
_bankService.QueryCusBankParamConfig(accountid, QueryBankparamConfigCallback, ErrorCallback);
})), () => IsBusy = false);
}
private void QueryBankparamConfigCallback(List bankconfigs)
{
IsBusy = false;
var bankConfig = bankconfigs.FirstOrDefault((item) => item.CusBankId == CurrentSigningBank.CusBankID);
_cusBankInfo = bankconfigs;
if (bankConfig != null && !string.IsNullOrEmpty(bankConfig.BankListId))
{
//根据配置字段过滤总行
if (this.BankListSource == null || this.BankListSource.Count<=0)
{
var queryCommons = new List();
_bankService.QueryCommonBankInfo(queryCommons, QueryBankInfoCallback, ErrorCallback);
}
else
{
SetbankListInfo(bankConfig);
}
}
else
{
MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_ChooseSignBankParameterSetError, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
this.BankList = null;
_view.bnt_OK.IsEnabled = false;
}
if (CurrentSigningBank.CusBankID == 2)
{
//this.BranchMessage = Visibility.Visible;
_view.bnt_OK.IsEnabled = false;
}
}
private void SetbankListInfo(CusBankInfo signingBank)
{
string[] bankListId = signingBank.BankListId.Split(',');
List bankList = new List();
foreach (string item in bankListId)
{
var bankId = item.Trim((@"\r\n").ToCharArray());
Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
if (bank != null)
{
bankList.Add(bank);
}
}
this.BankList = new ObservableCollection(bankList);
this.SelectBankItem = bankList.FirstOrDefault();
_view.bnt_OK.IsEnabled = true;
}
private void QueryBankList()
{
var bankConfig = _cusBankInfo.FirstOrDefault((item) => item.CusBankId == CurrentSigningBank.CusBankID);
//根据配置字段过滤总行
if (bankConfig != null && !string.IsNullOrEmpty(bankConfig.BankListId))
{
var queryCommons = new List();
if (this.BankListSource == null || BankListSource.Count() == 0)
{
_bankService.QueryCommonBankInfo(queryCommons,QueryBankInfoCallback, ErrorCallback);
}
else
{
string[] bankListId = bankConfig.BankListId.Split(',');
List bankList = new List();
foreach (string item in bankListId)
{
var bankId = item.Trim((@"\r\n").ToCharArray());
Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
if (bank != null)
{
bankList.Add(bank);
}
}
this.SelectBankItem = bankList.FirstOrDefault(x => x.BankId == CurrentSigningBank.BankId);
this.BankList = new ObservableCollection(bankList);
_view.bnt_OK.IsEnabled = true;
}
}
else
{
MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Bank_SignBank_ParameterError, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Tips);
this.BankList = null;
_view.bnt_OK.IsEnabled = false;
}
}
public void QueryBankInfoCallback(List list)
{
IsBusy = false;
this.BankListSource = list;
//this.BankList = new ObservableCollection(list);
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
QueryBankList();
//string[] bankListId = this.CurrentSigningBank.BankListId.Split(',');
//List bankList = new List();
//foreach (string item in bankListId)
//{
// var bankId = item.Trim((@"\r\n").ToCharArray());
// Banks bank = this.BankListSource.FirstOrDefault(c => c.BankId == bankId);
// if (bank != null)
// {
// bankList.Add(bank);
// }
//}
//this.SelectBankItem = bankList.FirstOrDefault();
//this.BankList = new ObservableCollection(bankList);
//_view.bnt_OK.IsEnabled = true;
}));
}
private void QueryEncryptKeyCallback_ShowField_Draw_IdentifyCode(EncryptKey encryptKey)
{
if (String.IsNullOrEmpty(_encryptKey.SecretKey))
{
MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
}
}
private void QueryEncryptKeyCallback_ShowField_BankAccountPWD(EncryptKey encryptKey)
{
if (String.IsNullOrEmpty(_encryptKey.SecretKey))
{
MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Bank_NoGetIncryption, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error);
}
}
///
/// 临时结果
///
private BankSignResult temp_ankDealStatus;
public void BankCaneclSignCallback(BankSignResult bankDealStatus)
{
IsBusy = false;
//一般情况银行电话密码和银行取款密码只需要一个
bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
temp_ankDealStatus = bankDealStatus;
if (isSendBankKey && bankDealStatus.ReturnCode == 0)
{
var encryptHelper = new TasEncryptHelper();
if (_encryptKey == null)
{
var reqkey = new EncryptKeyRequest()
{
Currency =
(UserManager.CurrentTradeAccount.FundsAccounts == null ||
!UserManager.CurrentTradeAccount.FundsAccounts.Any())
? "RMB"
: UserManager.CurrentTradeAccount.FundsAccounts[0].Currency,
CusBankId = CurrentSigningBank.CusBankID+string.Empty
};
// _encryptKey =
_bankService.QueryEncryptKey(reqkey, QueryEncryptKeyCallback, ErrorCallback);
}
else
{
string encryptPwd = "";
if (CurrentSigningBank.BankPasswordVisibility)
{
encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
CurrentSigningBank.BankPassword);
}
else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
{
encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
CurrentSigningBank.DrawIdentifyCode);
}
var req = new SignBankPDW()
{
AccountCode = UserManager.CurrentTradeAccount.AccountCode,
ExchTicket = bankDealStatus.ExchTicket,
ExtOperatorID = bankDealStatus.ExtOperatorID,
CusBankId = CurrentSigningBank.CusBankID + string.Empty,
BankAccountPWD = encryptPwd,
Currency =
(UserManager.CurrentTradeAccount.FundsAccounts == null ||
!UserManager.CurrentTradeAccount.FundsAccounts.Any())
? "RMB"
: UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
};
//errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
_bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
}
}
SignBankPwdCallback(bankDealStatus.ReturnCode);
}
private void SignBankPwdCallback(int result)
{
var bankDealStatus = temp_ankDealStatus;
bool isSendBankKey = (CurrentSigningBank.BankPasswordVisibility || CurrentSigningBank.DrawIdentifyCodeVisibility);
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
if (result == 0)
{
if (isSendBankKey)
{
MessageBoxHelper.ShowSuccess(
Muchinfo.MTPClient.Resources.Client_Resource.Bank_TerminationSuccess,
Muchinfo.MTPClient.Resources.Client_Resource.APP_Tips);
if (bankDealStatus.Status == BankDealStatus.BankDealStatus__BankWebComfirm)
{
IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
var messageBox = new MsgAlter(bankDealStatus.WebAddress)
{
Owner = Application.Current.MainWindow,
WindowStartupLocation = WindowStartupLocation.CenterOwner
};
messageBox.ShowDialog();
}
}
else
{
// LogManager.WriteBankApplyLog(1, CurrentSigningBank, UserManager.CurrentTradeAccount);
switch (bankDealStatus.Status)
{
case BankDealStatus.BankDealStatus__Succeed:
MessageBoxHelper.ShowSuccess(
Muchinfo.MTPClient.Resources.Client_Resource
.Bank_TerminationSuccess,
Muchinfo.MTPClient.Resources.Client_Resource
.APP_Tips);
break;
case BankDealStatus.BankDealStatus__Pend:
MessageBoxHelper.ShowSuccess(
Muchinfo.MTPClient.Resources.Client_Resource
.Bank_BankTerminationInfoSubmit_Wait,
Muchinfo.MTPClient.Resources.Client_Resource
.APP_Tips);
break;
case BankDealStatus.BankDealStatus__BankWebComfirm:
try
{
IPHelper.OpenWebAddress(bankDealStatus.WebAddress);
}
catch (Exception)
{
throw new MuchinfoException(ExceptionManager.OpenIEError);
}
finally
{
var messageBox = new MsgAlter(bankDealStatus.WebAddress)
{
Owner = Application.Current.MainWindow,
WindowStartupLocation = WindowStartupLocation.CenterOwner
};
messageBox.ShowDialog();
}
break;
}
}
// win_BankUpdateView.DialogResult = true;
_view.DialogResult = true;
}
else
{
ErrorManager.ShowReturnError(bankDealStatus.ReturnCode, Muchinfo.MTPClient.Resources.Client_Resource.Bank_ErrotTips);
}
//win_BankUpdateView.bnt_OK.IsEnabled = true;
_view.bnt_OK.IsEnabled = true;
}));
}
private void QueryEncryptKeyCallback(EncryptKey encryptKey)
{
var encryptHelper = new TasEncryptHelper();
var bankDealStatus = temp_ankDealStatus;
string encryptPwd = "";
if (CurrentSigningBank.BankPasswordVisibility)
{
encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
CurrentSigningBank.BankPassword);
}
else if (CurrentSigningBank.DrawIdentifyCodeVisibility)
{
encryptPwd = encryptHelper.EncryptPassd(_encryptKey.SecretKey,
CurrentSigningBank.DrawIdentifyCode);
}
var req = new SignBankPDW()
{
AccountCode = UserManager.CurrentTradeAccount.AccountCode,
ExchTicket = bankDealStatus.ExchTicket,
ExtOperatorID = bankDealStatus.ExtOperatorID,
CusBankId = CurrentSigningBank.CusBankID + string.Empty,
BankAccountPWD = encryptPwd,
Currency =
(UserManager.CurrentTradeAccount.FundsAccounts == null ||
!UserManager.CurrentTradeAccount.FundsAccounts.Any())
? "RMB"
: UserManager.CurrentTradeAccount.FundsAccounts[0].Currency
};
//errorCode =_bankService.SignBankPwd(req, UserManager.CurrentTradeAccount.LoginCode);
_bankService.SignBankPwd(req, SignBankPwdCallback, ErrorCallback);
SignBankPwdCallback(bankDealStatus.ReturnCode);
}
public void ErrorCallback(ErrorEntity error)
{
IsBusy = false;
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
ErrorManager.ShowReturnError(error, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error, true);
}));
}
}
}