コード例 #1
0
void BeamColumnJoint3d::formTransfMat()
{
	Transf.Zero();
	Tran.Zero();
	
	double Crd24 = fabs(sqrt((Node2(0)*Node2(0)) + (Node2(1)*Node2(1)) + (Node2(2)*Node2(2))));
	double Crd31 = fabs(sqrt((Node3(0)*Node3(0)) + (Node3(1)*Node3(1)) + (Node3(2)*Node3(2))));

	double a24 = Node2(0)/Crd24; double b24 = Node2(1)/Crd24; double c24 = Node2(2)/Crd24; 
    double a31 = Node3(0)/Crd31; double b31 = Node3(1)/Crd31; double c31 = Node3(2)/Crd31; 

	Tran(0,0) = a24; Tran(0,1) =  b24; Tran(0,2) = c24;
	Tran(1,0) = a31; Tran(1,1) =  b31; Tran(1,2) = c31;
	Tran(2,3) = b24*c31 - b31*c24; Tran(2,4) = -a24*c31 + c24*a31; Tran(2,5) = a24*b31 - b24*a31;
  
	Transf.Assemble(Tran,0,0,1.0);
	Transf.Assemble(Tran,3,6,1.0);
	Transf.Assemble(Tran,6,12,1.0);
	Transf.Assemble(Tran,9,18,1.0);

}
コード例 #2
0
ファイル: UnitComboBox.cpp プロジェクト: uesoft/AutoPFA
void CUnitComboBox::OnSelendOk() 
{
	// TODO: Add your control notification handler code here
	if(m_pWnd1 != NULL)
	{
		DWORD style1 = m_pWnd1->GetStyle();
		DWORD style2 = style1;
		style2 &=~ES_READONLY;
		if(style1 != style2)
			Tran(m_pWnd1);
	}
//	if(m_pWnd2 != NULL)
//	{
//		Tran(m_pWnd2);
//	}
}
コード例 #3
0
/*!
	This function is called when an authorization request is received from an acquirer gateway or from POS terminal. 
	When we receive such a message, we do all syntax checking, and if everything is OK, we process the request locally.
*/
void	CISO8583AuthorizerServerSession::OnAuthorizationRequest(CMultiXAppMsg &Msg,CISO8583Msg	&ISOMsg)
{
	std::string	Temp;
	double Amount;

	//	Check that we have PAN
	if(ISOMsg.PAN().length()	==	0)
	{
		Msg.Reply(CISO8583Msg::PANIsMissing);
		return;
	}

	//	Check the transaction amount for existance.
	Temp	=	ISOMsg.TransactionAmount();
	if(Temp	==	"")
	{
		Msg.Reply(CISO8583Msg::TransactionAmountIsMissing);
		return;
	}

	//	We save the amount in decimal format for later checking against the database
	Amount	=	(double)CISO8583Utilities::ToInt64(Temp)/100;

	//	Check that we got STAN
	if(ISOMsg.STAN().length()	==	0)
	{
		Msg.Reply(CISO8583Msg::STANIsMissing);
		return;
	}

	//	Check that we got Local Date and Time
	if(ISOMsg.TransactionTime().length() ==	0 ||	ISOMsg.TransactionDate().length()	==	0)
	{
		Msg.Reply(CISO8583Msg::DateTimeLocalIsMissing);
		return;
	}

	int	MerchantAccount	=	(int)CISO8583Utilities::ToInt64(ISOMsg.CardAcceptorIdentificationCode().StringData());
	if(!IsValidMerchant(MerchantAccount))
	{
		Msg.Reply(CISO8583Msg::RequestRejected);
		return;
	}

	std::vector<customer_account>	DataSet;

	if(PANToIssuerCode(ISOMsg.PAN().c_str())	!=	Owner()->OurIssuerIdentificationCode())
	{
		//	This is a foriegn card, we check that we support the issuer
		mysqlpp::Query Query = Owner()->DBConn().query();
		Query << "select * from customer_account where AccountNumber = %0";
		Query.parse();
		DataSet.clear();
		Query.storein(DataSet,CISO8583Utilities::ToString(PANToIssuerAccount(ISOMsg.PAN().c_str())).c_str());
		if(DataSet.empty())
		{
			//	we have not found the record in the database. so we try forwarding the request to the issuer
			Msg.Reply(CISO8583Msg::RequestRejected);
		}	else
		{
			ForwardToIssuer(PANToOurAccountAtIssuer(ISOMsg.PAN().c_str()),Msg,ISOMsg);
		}
		return;
	}
	/*
		After we finish all validation, we query the database for the card number and the balance
		We retrieve the record from the database based on the PAN specified in the request
	*/

  mysqlpp::Query Query = Owner()->DBConn().query();
	Query << "select * from customer_account where CardNumber = %0q";
	Query.parse();
	DataSet.clear();
	Query.storein(DataSet,ISOMsg.PAN().c_str());
	if(DataSet.empty())
	{
		//	we have not found the record in the database. so we try forwarding the request to the issuer
		Msg.Reply(CISO8583Msg::RequestRejected);
		return;
	}

	//	Lets make sure that we have enough money in the account

	if(DataSet[0].CurrentBalance	<	Amount)
	{
		Msg.Reply(CISO8583Msg::RequestRejected);
		return;
	}

	//	lets write a transaction log record to the data base

	mysqlpp::Transaction	Tran(Owner()->DBConn());
  mysqlpp::Query TransLogQuery = Owner()->DBConn().query();
	transactions_log	Log;
	Log.Time			=	TomysqlppDateTime(time(NULL));
	Log.AccountNumber	=	DataSet[0].AccountNumber;
	Log.CardNumber		=	DataSet[0].CardNumber;
	Log.Action				=	1;	//	Query
	Log.Amount				=	Amount;
	Log.NewBalance		=	DataSet[0].CurrentBalance;
	TransLogQuery.insert(Log);
	mysqlpp::ResNSel	Res	=	TransLogQuery.execute();
	Tran.commit();


	//	we can approve the authorization now.
	ISOMsg.SetMTI(ISOMsg.MTI() +	10);	//	this is a response
	ISOMsg.SetTimes(time(NULL),true);	//	This will set transmission time
	ISOMsg.SetDateTimeLocal(ISOMsg.DateTimeLocal());

	/* here we set balance in the response - if required 

	char	BalanceString[200];
	sprintf(BalanceString,"0001000%c%s",DataSet[0].CurrentBalance < 0 ? 'D' : 'C',CISO8583Utilities::ToString((int64_t)(DataSet[0].CurrentBalance * 100),12).c_str());
	CISO8583ElementValue	BalanceValue(BalanceString,CISO8583ElementValue::ISO8583ElementTypeAlphaNumeric);
	ISOMsg.SetAdditionalAmounts(BalanceValue);
	*/


	if(ISOMsg.Version()	==	CISO8583Msg::ISO8583_1_1987)
		ISOMsg.SetActionCode(std::string("00"));
	else
		ISOMsg.SetActionCode(std::string("000"));
	CISO8583Msg::TValidationError	Error	=	ISOMsg.ToISO();
	if(Error	!=	CISO8583Msg::NoError)
		Throw();
	/*
		we are done preparing the response, we reply with an MTI = CISO8583Msg::MTIAuthorizationMessageResponse
		and the handling is complete.
	*/

	Msg.Reply(ISOMsg.MTI(),ISOMsg.ISOBuffer(),ISOMsg.ISOBufferSize());
}
コード例 #4
0
//!	see CMultiXSession::OnDataReplyReceived
void	CISO8583AuthorizerServerSession::OnDataReplyReceived(CMultiXAppMsg &ReplyMsg,CMultiXAppMsg &ForwardedMsg)
{
	DebugPrint(3,"Data Reply Received\n");

	switch(CISO8583Msg::VersionIndependentMTI(ForwardedMsg.MsgCode()))	//	this will give us version independent MTI
	{
	case	CISO8583Msg::MTIAuthorizationMessageRequest	:
	case	CISO8583Msg::MTIFinancialMessageRequest	:
		{
			CMultiXAppMsg	*AcquirerMsg	=	(CMultiXAppMsg	*)ForwardedMsg.SavedContext();
			if(ReplyMsg.AppDataSize()	==	0)
			{
				AcquirerMsg->Reply(ReplyMsg.Error());
				delete	AcquirerMsg;
				break;
			}

			CISO8583Msg	AcquirerISO;
			CISO8583Msg	ReplyISO;
			AcquirerISO.FromISO((const	byte_t	*)AcquirerMsg->AppData(),AcquirerMsg->AppDataSize());
			ReplyISO.FromISO((const	byte_t	*)ReplyMsg.AppData(),ReplyMsg.AppDataSize());


			/*
				before we send the reply, we need to check if it is MTI 200 and if the response is positive, if so	:
				1. we debit the issuer account for the sales amount + commission. in this sample we derive the issuer account from the PAN.
				2. we credit our own account for these amounts
				3. we write transactions log.
			*/

			if(CISO8583Msg::VersionIndependentMTI(AcquirerMsg->MsgCode())	==	CISO8583Msg::MTIFinancialMessageRequest)
			{
				if(CISO8583Utilities::ToInt64(ReplyISO.ActionCode())	==	0)
				{
					double	Amount	=	(double)CISO8583Utilities::ToInt64(ReplyISO.TransactionAmount())/100;
					int	IssuerAccount	=	PANToIssuerAccount(AcquirerISO.PAN());
					int	MerchantAccount	=	(int)CISO8583Utilities::ToInt64(AcquirerISO.CardAcceptorIdentificationCode().StringData());
					if(!UpdateAuthorizedSale(IssuerAccount,MerchantAccount,AcquirerISO.PAN(),Amount))
					{
						AcquirerMsg->Reply(CISO8583Msg::RequestRejected);
		//				SendReversalToIssuer(ReplyISO); not implemented
						delete	AcquirerMsg;
						return;
					}
				}
			}	else	if(CISO8583Msg::VersionIndependentMTI(AcquirerMsg->MsgCode())	==	CISO8583Msg::MTIAuthorizationMessageRequest)
			{
				int	IssuerAccount	=	PANToIssuerAccount(AcquirerISO.PAN());
				double	Amount	=	(double)CISO8583Utilities::ToInt64(AcquirerISO.TransactionAmount())/100;

				mysqlpp::Transaction	Tran(Owner()->DBConn());
				mysqlpp::Query Query = Owner()->DBConn().query();
				transactions_log	Log;
				Log.Time			=	TomysqlppDateTime(time(NULL));
				Log.AccountNumber	=	IssuerAccount;
				Log.CardNumber		=	AcquirerISO.PAN();
				Log.Action				=	11;	//	Query
				Log.Amount				=	Amount;
				Log.NewBalance		=	0;
				Query.insert(Log);
				Query.execute();
				Tran.commit();
			}

			/*
				We get here when we receive a response for a message we forwarded before. In this case we will forward the response back to
				the originator, we do not care for the content, we forward it back almost AS IS except for few fields that
				we need to restore because changed them before we forwarded the message, the fields are:

				BMP 7 - Set Transmission time
				BMP 11 - restore sender STAN
				BMP 12	-	Restore sender Date and Time Local
				BMP 32 - Restore senders Acquiring Institution Identification Code
			*/
			/*
				In order to restore old values, we need to restore the message we received originaly from the acquirer or from the pos terminal.
				this message is saved in the SaveContext() of the ForwardedMsg.
			*/



			ReplyISO.SetTimes(time(NULL),true);
			ReplyISO.SetSTAN(AcquirerISO.STAN());
			ReplyISO.SetDateTimeLocal(AcquirerISO.DateTimeLocal());
			ReplyISO.SetAcquiringInstitutionIdentificationCode(AcquirerISO.AcquiringInstitutionIdentificationCode());
			ReplyISO.ToISO();


			AcquirerMsg->Reply(AcquirerMsg->MsgCode(),
				ReplyISO.ISOBuffer(),
				ReplyISO.ISOBufferSize(),0,0,0,0,0,ReplyMsg.Error());

			delete	AcquirerMsg;	//	WE MUST DELETE THE MESSAGE BECAUSE WE CALLED "Keep()" BEFORE WE FORWARDED IT.




		}
		break;
	}



	
	/*	
		we reply the ReplyMsg for the case that the process that replied to us expects to receive a notification that we
		received the reply, if it does not wait for the reply, no reply is sent.
	*/
	ReplyMsg.Reply();	
}
コード例 #5
0
bool	CISO8583AuthorizerServerSession::UpdateAuthorizedSale(int	DebitAccount,int	CreditAccount,std::string CustomerCard,double	Amount)
{

	mysqlpp::Transaction	Tran(Owner()->DBConn());
  mysqlpp::Query Query = Owner()->DBConn().query();
	std::vector<customer_account>	DataSet;

	/***************************************************************
	*	Debit the account for the sales + commission amount;
	***************************************************************/

	Query << "select * from customer_account where AccountNumber = %0";
	Query.parse();
	Query.storein(DataSet,CISO8583Utilities::ToString(DebitAccount).c_str());
	if(DataSet.empty())
	{
		//	we have no account to debit, we reject the transaction
		return	false;
	}

	//	let update the new balance
	customer_account	Row	=	DataSet[0];
	Row.CurrentBalance	-=	(Amount	+	Owner()->TransactionsCommission());
	Query.update(DataSet[0],Row);
	mysqlpp::ResNSel	Res	=	Query.execute();
	if(!Res)
	{
		return	false;
	}

	//	write the transaction log for the sales amount
	Query.reset();
	transactions_log	Log;
	Log.Time			=	TomysqlppDateTime(time(NULL));
	Log.AccountNumber	=	DebitAccount;
	Log.CardNumber		=	CustomerCard;
	Log.Action				=	2;	//	withdrawal
	Log.Amount				=	Amount;
	Log.NewBalance		=	Row.CurrentBalance	+	Owner()->TransactionsCommission();	//	the new balance
	Query.insert(Log);
	Query.execute();

	//	write the transaction log for the commission
	Query.reset();
	Log.Time			=	TomysqlppDateTime(time(NULL));
	Log.AccountNumber	=	DebitAccount;
	Log.CardNumber		=	CustomerCard;
	Log.Action				=	12;	//	withdrawal
	Log.Amount				=	Owner()->TransactionsCommission();
	Log.NewBalance		=	Row.CurrentBalance;	//	the new balance
	Query.insert(Log);
	Query.execute();

	/***************************************************************
	*	END Debit the account for the sales + commission amount;
	***************************************************************/


	/***************************************************************
	*	Credit account for the sales amount;
	***************************************************************/

	Query.reset();
	DataSet.clear();

	Query << "select * from customer_account where AccountNumber = %0";
	Query.parse();
	Query.storein(DataSet,CISO8583Utilities::ToString(CreditAccount).c_str());
	if(DataSet.empty())
	{
		//	we have no credit account, we reject the transaction
		return false;
	}

	//	let update the new balance
	Row	=	DataSet[0];
	Row.CurrentBalance	+=	Amount;
	Query.update(DataSet[0],Row);
	Res	=	Query.execute();
	if(!Res)
	{
		return	false;
	}


	/***************************************************************
	*	Credit our account for the commission;
	***************************************************************/

	Query.reset();
	DataSet.clear();

	Query << "select * from customer_account where AccountNumber = %0";
	Query.parse();
	Query.storein(DataSet,CISO8583Utilities::ToString(Owner()->OurCreditAccount()).c_str());
	if(DataSet.empty())
	{
		//	we have no credit account, we reject the transaction
		return false;
	}

	//	let update the new balance
	Row	=	DataSet[0];
	Row.CurrentBalance	+=	Owner()->TransactionsCommission();
	Query.update(DataSet[0],Row);
	Res	=	Query.execute();
	if(!Res)
	{
		return	false;
	}

	/***************************************************************
	*	END Credit Our account for the sales + commission amount;
	***************************************************************/
	Tran.commit();

	return	true;

}