改c
This commit is contained in:
		@@ -24,6 +24,7 @@
 | 
			
		||||
    <ClCompile Include="..\..\..\source\Data\Datastructure\CarDealerScheme\CarDealerScheme.cpp" />
 | 
			
		||||
    <ClCompile Include="..\..\..\source\data\Datastructure\RepairOrder\RepairOrder.cpp" />
 | 
			
		||||
    <ClCompile Include="..\..\..\source\data\excel\excel.cpp" />
 | 
			
		||||
    <ClCompile Include="..\..\..\source\db\ocilib\db_oper.cpp" />
 | 
			
		||||
    <ClCompile Include="..\..\..\source\main.cpp" />
 | 
			
		||||
    <ClCompile Include="..\..\..\source\system\system_util.cpp" />
 | 
			
		||||
    <ClCompile Include="..\..\..\source\test\test.cpp" />
 | 
			
		||||
@@ -46,6 +47,7 @@
 | 
			
		||||
    <ClInclude Include="..\..\..\source\Data\Datastructure\CarDealerScheme\CarDealerScheme.h" />
 | 
			
		||||
    <ClInclude Include="..\..\..\source\data\Datastructure\RepairOrder\RepairOrder.h" />
 | 
			
		||||
    <ClInclude Include="..\..\..\source\data\excel\excel.h" />
 | 
			
		||||
    <ClInclude Include="..\..\..\source\db\ocilib\db_oper.h" />
 | 
			
		||||
    <ClInclude Include="..\..\..\source\system\system_util.h" />
 | 
			
		||||
    <ClInclude Include="..\..\..\source\test\test.h" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 
 | 
			
		||||
@@ -65,6 +65,12 @@
 | 
			
		||||
    <Filter Include="数据\数据管理\导入导出\oracle">
 | 
			
		||||
      <UniqueIdentifier>{cfe6b511-cb09-441f-8496-69415615391a}</UniqueIdentifier>
 | 
			
		||||
    </Filter>
 | 
			
		||||
    <Filter Include="数据库">
 | 
			
		||||
      <UniqueIdentifier>{6e142c33-b01c-4c8d-b8a4-beaaee863cee}</UniqueIdentifier>
 | 
			
		||||
    </Filter>
 | 
			
		||||
    <Filter Include="数据库\ocilib">
 | 
			
		||||
      <UniqueIdentifier>{e5f3c3be-5fe7-471e-8dc7-d5889f5f87d9}</UniqueIdentifier>
 | 
			
		||||
    </Filter>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ClCompile Include="..\..\..\source\main.cpp">
 | 
			
		||||
@@ -100,6 +106,9 @@
 | 
			
		||||
    <ClCompile Include="..\..\..\source\Data\DataManipulation\oracle\ImportToOracle.cpp">
 | 
			
		||||
      <Filter>数据\数据管理\导入导出\oracle</Filter>
 | 
			
		||||
    </ClCompile>
 | 
			
		||||
    <ClCompile Include="..\..\..\source\db\ocilib\db_oper.cpp">
 | 
			
		||||
      <Filter>数据库\ocilib</Filter>
 | 
			
		||||
    </ClCompile>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <QtRcc Include="..\..\..\source\resource.qrc">
 | 
			
		||||
@@ -154,5 +163,8 @@
 | 
			
		||||
    <ClInclude Include="..\..\..\source\Data\DataManipulation\oracle\ImportToOracle.h">
 | 
			
		||||
      <Filter>数据\数据管理\导入导出\oracle</Filter>
 | 
			
		||||
    </ClInclude>
 | 
			
		||||
    <ClInclude Include="..\..\..\source\db\ocilib\db_oper.h">
 | 
			
		||||
      <Filter>数据库\ocilib</Filter>
 | 
			
		||||
    </ClInclude>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
</Project>
 | 
			
		||||
@@ -6,6 +6,16 @@
 | 
			
		||||
using namespace std;
 | 
			
		||||
using namespace ocilib;
 | 
			
		||||
 | 
			
		||||
void l_error_handler(OCI_Error* pError)
 | 
			
		||||
{
 | 
			
		||||
	string errorString = OCI_ErrorGetString(pError);
 | 
			
		||||
 | 
			
		||||
	std::runtime_error error(OCI_ErrorGetString(pError));
 | 
			
		||||
 | 
			
		||||
	throw error;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
void ImportCarDealerAchievementToOracle( std::string                         userName,
 | 
			
		||||
                                         std::string                         password,
 | 
			
		||||
                                         std::string                         tnsName,
 | 
			
		||||
@@ -72,15 +82,15 @@ void ImportCarDealerAchievementToOracle( std::string                         use
 | 
			
		||||
			string pinganAmount       = QString( "%1" ).arg( iter->getPinganAmount() ).toStdString();
 | 
			
		||||
			string othersAmount       = QString( "%1" ).arg( iter->getOthersAmount() ).toStdString();
 | 
			
		||||
 | 
			
		||||
			pStmt->Bind( ":a_the_year", QString::fromStdWString( iter->getTheYear() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_the_month", QString::fromStdWString( iter->getTheMonth() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_car_dealer_code", QString::fromStdWString( iter->getCarDealerCode() ).toStdString(), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_checked_achievement", checkedAchievement, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_policy_amount", policyAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_cpic_amount", cpicAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_picc_amount", piccAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_pingan_amount", pinganAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind( ":a_others_amount", othersAmount, BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>( ostring(":a_the_year"), ostring(QString::fromStdWString( iter->getTheYear() ).toStdString().c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_the_month"), ostring(QString::fromStdWString( iter->getTheMonth() ).toStdString().c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_car_dealer_code"), ostring(QString::fromStdWString( iter->getCarDealerCode() ).toStdString().c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_checked_achievement"), ostring(checkedAchievement.c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_policy_amount"), ostring(policyAmount.c_str()), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_cpic_amount"), ostring(cpicAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_picc_amount"), ostring(piccAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_pingan_amount"), ostring(pinganAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
			pStmt->Bind<ostring>(ostring(":a_others_amount"), ostring(othersAmount), BindInfo::BindDirectionValues::In );
 | 
			
		||||
 | 
			
		||||
			pStmt->ExecutePrepared();
 | 
			
		||||
		}
 | 
			
		||||
@@ -97,6 +107,30 @@ void ImportCarDealerAchievementToOracle( std::string                         use
 | 
			
		||||
 | 
			
		||||
	Environment::Cleanup();
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
void ImportCarDealerAchievementToOracle( std::string                         userName,
 | 
			
		||||
                                         std::string                         password,
 | 
			
		||||
                                         std::string                         tnsName,
 | 
			
		||||
                                         std::vector<CarDealerAchievement> & achievementVector )
 | 
			
		||||
{
 | 
			
		||||
	OCI_Connection * pConnection = nullptr;
 | 
			
		||||
	OCI_Statement *  pStatement  = nullptr;
 | 
			
		||||
 | 
			
		||||
	ostring sqlImport =
 | 
			
		||||
			"BEGIN "
 | 
			
		||||
			"  car_dealer.data_import_util_pkg.import_cardealer_achvmnt( :a_the_year, "
 | 
			
		||||
			"                                                            :a_the_month, "
 | 
			
		||||
			"                                                            :a_car_dealer_code, "
 | 
			
		||||
			"                                                            :a_checked_achievement, "
 | 
			
		||||
			"                                                            :a_policy_amount, "
 | 
			
		||||
			"                                                            :a_cpic_amount, "
 | 
			
		||||
			"                                                            :a_picc_amount , "
 | 
			
		||||
			"                                                            :a_pingan_amount, "
 | 
			
		||||
			"                                                            :a_others_amount ); "
 | 
			
		||||
			"END; ";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void ImportRepairOrderToOracle( std::string                userName,
 | 
			
		||||
                                std::string                password,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										67
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
			
		||||
 | 
			
		||||
#include <exception>
 | 
			
		||||
#include <stdexcept>
 | 
			
		||||
#include "db_oper.h"
 | 
			
		||||
 | 
			
		||||
const int ERROR_MESSAGE_LENGTH = 1001;
 | 
			
		||||
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
void get_error_message(OCI_Error * pError, char * pszMessage, size_t length);
 | 
			
		||||
 | 
			
		||||
void initOciLib()
 | 
			
		||||
{
 | 
			
		||||
	int    returnCode = 0;
 | 
			
		||||
	char * pszErrorMessage = (char *)malloc(sizeof(char) * ERROR_MESSAGE_LENGTH);
 | 
			
		||||
 | 
			
		||||
	returnCode = OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
 | 
			
		||||
 | 
			
		||||
	if (!returnCode )
 | 
			
		||||
	{
 | 
			
		||||
		get_error_message(OCI_GetLastError(), pszErrorMessage, ERROR_MESSAGE_LENGTH - 1);
 | 
			
		||||
 | 
			
		||||
		string message("OCILIB初始化失败!\n");
 | 
			
		||||
 | 
			
		||||
		message += pszErrorMessage;
 | 
			
		||||
 | 
			
		||||
		throw runtime_error(message);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	free(pszErrorMessage);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void releaseOciLib()
 | 
			
		||||
{
 | 
			
		||||
	OCI_Cleanup();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void get_error_message(OCI_Error * pError, char * pszMessage, size_t length)
 | 
			
		||||
{
 | 
			
		||||
	//防御性验证
 | 
			
		||||
	if (pError == NULL)
 | 
			
		||||
	{
 | 
			
		||||
		pszMessage[0] = NULL;
 | 
			
		||||
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const otext * psz = OCI_ErrorGetString(pError);
 | 
			
		||||
 | 
			
		||||
	strcpy_s(pszMessage, length, psz);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void error_handler(OCI_Error * pError)
 | 
			
		||||
{
 | 
			
		||||
	std::runtime_error error(OCI_ErrorGetString(pError));
 | 
			
		||||
 | 
			
		||||
	OCI_Cleanup();
 | 
			
		||||
 | 
			
		||||
	throw error;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string get_last_error_message()
 | 
			
		||||
{
 | 
			
		||||
	OCI_Error * pError = OCI_GetLastError();
 | 
			
		||||
 | 
			
		||||
	return std::string(OCI_ErrorGetString(pError));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								代码/cpp/car_dealer_util/source/db/ocilib/db_oper.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
 | 
			
		||||
#ifndef _DB_OPER_H
 | 
			
		||||
#define _DB_OPER_H
 | 
			
		||||
 | 
			
		||||
#include <ocilib.h>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <unordered_map>
 | 
			
		||||
 | 
			
		||||
void initOciLib();
 | 
			
		||||
 | 
			
		||||
void releaseOciLib();
 | 
			
		||||
 | 
			
		||||
void error_handler(OCI_Error * pError);
 | 
			
		||||
 | 
			
		||||
std::string get_last_error_message();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Reference in New Issue
	
	Block a user