Exemplo n.º 1
0
//*=================================================================================
//*原型: void TSmartTask::Initialized(LPCTSTR pszFileName)
//*功能: 初始化任务库
//*参数: 略
//*返回: 成功与否
//*说明: 任务处理
//*=================================================================================
void TSmartTask::Initialized(LPCTSTR pszFileName)
{
	m_hModule = LoadLibrary(pszFileName);
	if( m_hModule == NULL )
		throw TException("不能装入任务管理动态库!", GetLastError());

    InitTaskDLL = (lpfnInitTaskDLL)GetProcAddress(m_hModule, "InitTaskDLL");
    DestoryTaskDLL = (lpfnDestoryTaskDLL)GetProcAddress(m_hModule, "DestoryTaskDLL");
    ReadTask = (lpfnReadTask)GetProcAddress(m_hModule, "ReadTask");
    ReadTSRTask = (lpfnReadTSRTask)GetProcAddress(m_hModule, "ReadTSRTask");
    TaskReplace = (lpfnTaskReplace)GetProcAddress(m_hModule, "TaskReplace");
    GetTimeOutMap = (lpfnGetTimeOutMap)GetProcAddress(m_hModule, "GetTimeOutMap");
	UpdateTask =  (lpfnUpdateTask)GetProcAddress(m_hModule, "UpdateTask");
	ReadSmartDocInfo =  (lpfnReadSmartDocInfo)GetProcAddress(m_hModule, "ReadSmartDocInfo");
	ReleaseSmartDoc =  (lpfnReleaseSmartDoc)GetProcAddress(m_hModule, "ReleaseSmartDoc");

	if( !InitTaskDLL || !DestoryTaskDLL || !ReadTask || 
		!ReadTSRTask || !TaskReplace || !GetTimeOutMap || !UpdateTask || 
		!ReadSmartDocInfo || !ReleaseSmartDoc )
	{
		FreeLibrary(m_hModule);
		m_hModule = NULL ;
		throw TException("不是合法的任务管理动态库!");
	}

	if( InitTaskDLL(&SmartFunction) != RET_OK )
	{
		FreeLibrary(m_hModule);
		m_hModule = NULL ;
		throw TException("任务管理动态库初始化错误!");
	}
}
Exemplo n.º 2
0
void TEvhttpClientChannel::finish(struct evhttp_request* req) {
  if (req == NULL) {
    try {
      cob_();
    } catch (const TTransportException& e) {
      if (e.getType() == TTransportException::END_OF_FILE)
        throw TException("connect failed");
      else
        throw;
    }
    return;
  } else if (req->response_code != 200) {
    try {
      cob_();
    } catch (const TTransportException& e) {
      std::stringstream ss;
      ss << "server returned code " << req->response_code;
      if (req->response_code_line)
        ss << ": " << req->response_code_line;
      if (e.getType() == TTransportException::END_OF_FILE)
        throw TException(ss.str());
      else
        throw;
    }
    return;
  }
  recvBuf_->resetBuffer(EVBUFFER_DATA(req->input_buffer),
                        static_cast<uint32_t>(EVBUFFER_LENGTH(req->input_buffer)));
  cob_();
  return;
}
Exemplo n.º 3
0
//*=================================================================================
//*原型: void TServer::DeleteService(LPCTSTR pszServiceName)
//*功能: 删除服务
//*参数: pszServiceName -- 服务名称
//*返回: 无
//*说明: WINNT服务器基类
//*=================================================================================
void TServer::DeleteService(LPCTSTR pszServiceName)
{
	SC_HANDLE  schSCManager;

	schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
	if( schSCManager == NULL )
	{
		throw TException("Call OpenSCManager() Faild!", 
				GetLastError());
	}

    SC_HANDLE schService = OpenService(schSCManager, pszServiceName, DELETE);
	if( schService == NULL )
	{
	    CloseServiceHandle(schSCManager);
		throw TException("服务器还没有安装!");
	}

	if( !::DeleteService(schService) )
	{
	    CloseServiceHandle(schService);
		CloseServiceHandle(schSCManager);
		throw TException("删除服务器失败!", 
				GetLastError());
	}

	TCHAR  szModuleName[MAX_PATH];
	wsprintf(szModuleName, "删除服务%s成功!", pszServiceName);
	MessageBox(NULL, szModuleName, SERVICE_TITLE, MB_OK|MB_ICONINFORMATION);

    CloseServiceHandle(schService);
	CloseServiceHandle(schSCManager);

	return ;
}
Exemplo n.º 4
0
//*==================================================================
//*原型: void TSmartModule::Initialized(LPCTSTR pszFileName)
//*功能: 初始化SmartModule
//*参数: 略
//*返回: 无
//*说明: 业务功能插件
//*==================================================================
void TSmartModule::Initialized(LPCTSTR pszFileName)
{
	m_hModule = LoadLibrary(pszFileName);
	if( m_hModule == NULL )
	{
		TCHAR szText[384];
		delete this;

		wsprintf(szText, "不能装入业务功能动态库%s!", pszFileName);
		throw TException(szText, GetLastError());
	}

	m_InitModuleDLL = (lpfnInitModule)GetProcAddress(m_hModule, "InitModuleDLL");
	m_DestoryModuleDLL = (lpfnDestoryModule)GetProcAddress(m_hModule, "DestoryModuleDLL");
	m_CreateTaskBuffer = (lpfnCreateTaskBuffer)GetProcAddress(m_hModule, "CreateTaskBuffer");
	m_SmartTaskProcess = (lpfnSmartTaskProcess)GetProcAddress(m_hModule, "SmartTaskProcess");

	if( !m_InitModuleDLL || !m_DestoryModuleDLL || 
		!m_CreateTaskBuffer || !m_SmartTaskProcess )
	{
		throw TException("非法的业务功能动态库!");
	}

	long nFlag = 0 ;

	if( m_InitModuleDLL(&SmartFunction, &m_Support) != RET_OK )
	{
		throw TException("业务功能动态库初始化失败!");
	}

	if( m_Support.nTaskCount <= 0 )
	{
		throw TException("非法的业务功能动态库!");
	}
}
Exemplo n.º 5
0
TEvhttpServer::TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor, int port)
  : processor_(processor), eb_(NULL), eh_(NULL) {
  // Create event_base and evhttp.
  eb_ = event_base_new();
  if (eb_ == NULL) {
    throw TException("event_base_new failed");
  }
  eh_ = evhttp_new(eb_);
  if (eh_ == NULL) {
    event_base_free(eb_);
    throw TException("evhttp_new failed");
  }

  // Bind to port.
  int ret = evhttp_bind_socket(eh_, NULL, port);
  if (ret < 0) {
    evhttp_free(eh_);
    event_base_free(eb_);
    throw TException("evhttp_bind_socket failed");
  }

  // Register a handler.  If you use the other constructor,
  // you will want to do this yourself.
  // Don't forget to unregister before destorying this TEvhttpServer.
  evhttp_set_cb(eh_, "/", request, (void*)this);
}
Exemplo n.º 6
0
//---------------------------------------------------------------------------
int TExecuteProgram::execute(){
	double returnValue=0.0;
		try{
            #if defined (__GNUC__) || (__clang__)
			// here should be a test if the file exists.....
			int pid, status;
			pid = fork();
			if (pid == -1)
			   throw TException("Calling program '" + myExe + "': not able to create fork!", _FATAL_ERROR);
			if (pid == 0)	execv(myParameter[0], myParameter);

			// wait that the process terminates
			if (wait (&status) != pid) {
				throw TException("Error when executing '" + myExe +"'!", _FATAL_ERROR);
			}
			if (WIFEXITED (status)) {
				  returnValue=WEXITSTATUS(status);
			} else {
	           returnValue=0;
			}
            #elif defined (_MSC_VER)
			returnValue=spawnv(P_WAIT, myParameter[0], myParameter);
			if(returnValue==-1)
				throw TException("Error when executing '" + myExe +"'!" + myExe + "'!", _FATAL_ERROR);
			#endif
		  }
		  catch(TException error){
		     throw;
		  }
		  catch (...){
		     throw TException("Error when executing '" + myExe +"'!", _FATAL_ERROR);
		  }
		return returnValue;

} // executeProgram
Exemplo n.º 7
0
TTimer::Imp::Imp(std::string name, UINT timerRes, TTimer::Type type,
                 TTimer *timer)
    : m_name(name)
    , m_timerRes(timerRes)
    , m_timer(timer)
    , m_type(type)
    , m_timerID(NULL)
    , m_ticks(0)
    , m_delay(0)
    , m_started(false)
    , m_action(0) {
  TIMECAPS tc;

  if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
    throw TException("Unable to create timer");
  }

  m_timerRes = std::min((int)std::max((int)tc.wPeriodMin, (int)m_timerRes),
                        (int)tc.wPeriodMax);
  timeBeginPeriod(m_timerRes);

  switch (type) {
  case TTimer::OneShot:
    m_type = TIME_ONESHOT;
    break;

  case TTimer::Periodic:
    m_type = TIME_PERIODIC;
    break;

  default:
    throw TException("Unexpected timer type");
    break;
  }
}
Exemplo n.º 8
0
/**
 * Takes a socket created by listenSocket() and sets various options on it
 * to prepare for use in the server.
 */
void TNonblockingServer::listenSocket(THRIFT_SOCKET s) {
  // Set socket to nonblocking mode
  int flags;
  if ((flags = THRIFT_FCNTL(s, THRIFT_F_GETFL, 0)) < 0
      || THRIFT_FCNTL(s, THRIFT_F_SETFL, flags | THRIFT_O_NONBLOCK) < 0) {
    ::THRIFT_CLOSESOCKET(s);
    throw TException("TNonblockingServer::serve() THRIFT_O_NONBLOCK");
  }

  int one = 1;
  struct linger ling = {0, 0};

  // Keepalive to ensure full result flushing
  setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, const_cast_sockopt(&one), sizeof(one));

  // Turn linger off to avoid hung sockets
  setsockopt(s, SOL_SOCKET, SO_LINGER, const_cast_sockopt(&ling), sizeof(ling));

// Set TCP nodelay if available, MAC OS X Hack
// See http://lists.danga.com/pipermail/memcached/2005-March/001240.html
#ifndef TCP_NOPUSH
  setsockopt(s, IPPROTO_TCP, TCP_NODELAY, const_cast_sockopt(&one), sizeof(one));
#endif

#ifdef TCP_LOW_MIN_RTO
  if (TSocket::getUseLowMinRto()) {
    setsockopt(s, IPPROTO_TCP, TCP_LOW_MIN_RTO, const_cast_sockopt(&one), sizeof(one));
  }
#endif

  if (listen(s, LISTEN_BACKLOG) == -1) {
    ::THRIFT_CLOSESOCKET(s);
    throw TException("TNonblockingServer::serve() listen");
  }

  // Cool, this socket is good to go, set it as the serverSocket_
  serverSocket_ = s;

  if (!port_) {
    struct sockaddr_storage addr;
    socklen_t size = sizeof(addr);
    if (!getsockname(serverSocket_, reinterpret_cast<sockaddr*>(&addr), &size)) {
      if (addr.ss_family == AF_INET6) {
        const struct sockaddr_in6* sin = reinterpret_cast<const struct sockaddr_in6*>(&addr);
        listenPort_ = ntohs(sin->sin6_port);
      } else {
        const struct sockaddr_in* sin = reinterpret_cast<const struct sockaddr_in*>(&addr);
        listenPort_ = ntohs(sin->sin_port);
      }
    } else {
      GlobalOutput.perror("TNonblocking: failed to get listen port: ", THRIFT_GET_SOCKET_ERROR);
    }
  }
}
Exemplo n.º 9
0
  void start(UINT delay) {
    if (m_started) throw TException("The timer is already started");

    m_timerID = timeSetEvent(delay, m_timerRes, (LPTIMECALLBACK)ElapsedTimeCB,
                             (DWORD)this, m_type | TIME_CALLBACK_FUNCTION);

    m_delay = delay;
    m_ticks = 0;
    if (m_timerID == NULL) throw TException("Unable to start timer");

    m_started = true;
  }
Exemplo n.º 10
0
//*=================================================================================
//*原型: void TServer::CheckInstance()
//*功能: 检测是否有本程序的副本在运行
//*参数: 无
//*返回: 无
//*说明: Windows NT服务器封装基类
//*=================================================================================
void TServer::CheckInstance()
{
	TCHAR  szMutexName[MAX_PATH];

	lstrcpy(szMutexName, _T("__SMART_CARD_SERVICE_RUNNING__"));
	m_hInstance = CreateMutex(NULL, TRUE, szMutexName);
	if( m_hInstance == NULL )
	{
		throw TException("程序已经运行!");
	}
	else if( m_hInstance != NULL && GetLastError() == ERROR_ALREADY_EXISTS )
	{
		throw TException("程序已经运行!");
	}
}
Exemplo n.º 11
0
int  StatDataEvent::GetCycle()
{
	static 	int				iPreBillingCycleID=0;
	static  int				iResult;

	BillingCycleMgr		billing_cycle_mgr;
	BillingCycle	*	pBillingCycle;
	
	char			sTemp[7];
	
	if ( iPreBillingCycleID==pRead->Get_BILLING_CYCLE_ID() )
		return iResult;
	else 
		iPreBillingCycleID=	pRead->Get_BILLING_CYCLE_ID();
		
	pBillingCycle=billing_cycle_mgr.getBillingCycle(pRead->Get_BILLING_CYCLE_ID());
	
	if ( !pBillingCycle ){
		char sTemp[200];
		sprintf(sTemp,"[%s:%d] billing_id=[%d]找不到!",__FILE__,__LINE__,(int )pRead->Get_BILLING_CYCLE_ID());
		throw TException(sTemp);
	}
	strncpy(sTemp,pBillingCycle->getEndDate(),6);
	sTemp[6]='\0';
	iResult=atoi(sTemp);
	return iResult;
	
}
Exemplo n.º 12
0
void TRop::blur(const TRasterP &dstRas, const TRasterP &srcRas, double blur,
                int dx, int dy, bool useSSE) {
  TRaster32P dstRas32 = dstRas;
  TRaster32P srcRas32 = srcRas;

  if (dstRas32 && srcRas32)
    doBlurRgb<TPixel32, UCHAR, float>(dstRas32, srcRas32, blur, dx, dy, useSSE);
  else {
    TRaster64P dstRas64 = dstRas;
    TRaster64P srcRas64 = srcRas;
    if (dstRas64 && srcRas64)
      doBlurRgb<TPixel64, USHORT, double>(dstRas64, srcRas64, blur, dx, dy,
                                          useSSE);
    else {
      TRasterGR8P dstRasGR8 = dstRas;
      TRasterGR8P srcRasGR8 = srcRas;

      if (dstRasGR8 && srcRasGR8)
        doBlurGray<TPixelGR8>(dstRasGR8, srcRasGR8, blur, dx, dy);
      else {
        TRasterGR16P dstRasGR16 = dstRas;
        TRasterGR16P srcRasGR16 = srcRas;

        if (dstRasGR16 && srcRasGR16)
          doBlurGray<TPixelGR16>(dstRasGR16, srcRasGR16, blur, dx, dy);
        else
          throw TException("TRop::blur unsupported pixel type");
      }
    }
  }
}
Exemplo n.º 13
0
bool StatPayment::GetRecordFromTable(POINT_TYPE &BreakPoint)		
{
	char sTemp[200];
	
	if ( !pRead){
        sprintf(sTemp,"[%s:%d] GetRecordFromTable 游标还没打开!",_FILE_NAME_,__LINE__);
		throw TException(sTemp);
    }
    
    if ( ! pRead->Next()){
        return false;
    }
  	
    BreakPoint=pRead->Get_PAYMENT_ID();
    
     
	/*    
    if (interface.getServ(serv,AcctBalance.Get_SERV_ID(),AcctBalance.Get_STATE_DATE()) ){
    	pServ=&serv;
    	pservinfo=serv.getServInfo();
    	pcustinfo=serv.getCustInfo();
	}
	else{
		pServ=NULL;
		pservinfo=NULL;
		pcustinfo=NULL;
	}
	*/
	return true;
}
void TestSpawnTeleport() {
    std::cout << "TEST EMPTY\n";
    TBoard board(8, 8);

    TUnit::TSegments segments = {
        TSegment(Coords::TColRowPoint(0, 0)),
        TSegment(Coords::TColRowPoint(1, 0)),
        TSegment(Coords::TColRowPoint(1, 1)),
        TSegment(Coords::TColRowPoint(2, 1)),
    };

    /*  xX */
    TUnit unit(
        TSegment(Coords::TColRowPoint(1, 0)),
        std::move(segments)
    );
    auto teleported = board.TeleportUnitToSpawnPosition(unit);
    if (teleported.GetPivot().GetPosition().Column != 4) {
        throw TException("TestSpawnTeleport error")
            << __FILE__ << ":" << __LINE__
            << " :\n" << teleported.GetPivot().GetPosition().Column << "\n"
            << "expected: 4"
        ;
    }
}
Exemplo n.º 15
0
bool	TBL_BALANCE_PAYOUT_CLASS::Next()
{
		if ( m_qry == NULL)
			throw TException("mqry not open!");
		try{
			if ( !m_qry->next())
				return false;
			item.OPER_PAYOUT_ID=m_qry->field("OPER_PAYOUT_ID").asLong();
			item.ACCT_BALANCE_ID=m_qry->field("ACCT_BALANCE_ID").asLong();
			item.BILLING_CYCLE_ID=m_qry->field("BILLING_CYCLE_ID").asLong();
			item.BILL_ID=m_qry->field("BILL_ID").asLong();
			strcpy(item.OPER_TYPE,m_qry->field("OPER_TYPE").asString());
			item.STAFF_ID=m_qry->field("STAFF_ID").asLong();
			strcpy(item.OPER_DATE,m_qry->field("OPER_DATE").asString());
			item.AMOUNT=m_qry->field("AMOUNT").asLong();
			item.BALANCE=m_qry->field("BALANCE").asLong();
			item.PRN_COUNT=m_qry->field("PRN_COUNT").asLong();
			strcpy(item.STATE,m_qry->field("STATE").asString());
			strcpy(item.STATE_DATE,m_qry->field("STATE_DATE").asString());
		return true;
		}
		catch (TOCIException &oe) {
			cout<<"Error occured ... in TBL_BALANCE_PAYOUT_CLASS.cpp"<<endl;
			cout<<oe.getErrMsg()<<endl;
			cout<<oe.getErrSrc()<<endl;
			throw oe;
		}
}
Exemplo n.º 16
0
void multiLinear(
	const TRasterP &ras,
	TPointD posTrasf,
	const TSpectrumParamP colors,
	double period,
	double count,
	double amplitude,
	double freq,
	double phase,
	double cycle,
	const TAffine &aff,
	double frame)
{
	if ((TRaster32P)ras)
		doComputeLinearT<TPixel32>(
			ras, posTrasf,
			colors->getValue(frame),
			period, count, amplitude, freq, phase, cycle, aff);
	else if ((TRaster64P)ras)
		doComputeLinearT<TPixel64>(
			ras, posTrasf,
			colors->getValue64(frame),
			period, count, amplitude, freq, phase, cycle, aff);
	else
		throw TException("MultiLinearGradientFx: unsupported Pixel Type");
}
Exemplo n.º 17
0
 void i_lexit (
     TExitLevel exit_level,
     int linenum,
     const char *filename,
     const char *functionname)
 {
   if (exit_level==df)
     exit_level= DEFAULT_EXIT_LEVEL;
   if (exit_level!=success && exit_level!=th)
     std::cerr<<ioscc::green<<"------"<<std::endl
       <<ioscc::green<<"the program is terminated"<<std::endl
       <<ioscc::green<<"  at "<<ioscc::blue<<filename<<ioscc::green<<":"
                             <<ioscc::blue<<linenum<<ioscc::green<<":"<<std::endl
       <<ioscc::green<<"  within the function: "<<ioscc::blue<<functionname<<std::endl;
   switch (exit_level)
   {
     case success :
       std::exit(EXIT_SUCCESS);
     case qfail   :
       std::exit(EXIT_FAILURE);
     case btfail  :
       std::cerr<<"backtrace:"<<std::endl;
       StackTrace();
       std::exit(EXIT_FAILURE);
     case abort   :
       std::abort();
     case th      :
       throw TException(linenum,filename,functionname);
     default      :
       std::cerr<<"improper usage of lexit(exit_level); invalid exit_level: "
         <<static_cast<int>(exit_level)<<std::endl;
       std::exit(EXIT_FAILURE);
   }
 }
Exemplo n.º 18
0
bool	TBL_ACCT_BALANCE_CLASS::Next()
{
		if ( m_qry == NULL)
			throw TException("mqry not open!");
		try{
			if ( !m_qry->next())
				return false;
			item.ACCT_BALANCE_ID=m_qry->field("ACCT_BALANCE_ID").asLong();
			item.BALANCE_TYPE_ID=m_qry->field("BALANCE_TYPE_ID").asLong();
			strcpy(item.EFF_DATE,m_qry->field("EFF_DATE").asString());
			strcpy(item.EXP_DATE,m_qry->field("EXP_DATE").asString());
			item.BALANCE=m_qry->field("BALANCE").asLong();
			item.CYCLE_UPPER=m_qry->field("CYCLE_UPPER").asLong();
			item.CYCLE_LOWER=m_qry->field("CYCLE_LOWER").asLong();
			strcpy(item.CYCLE_UPPER_TYPE,m_qry->field("CYCLE_UPPER_TYPE").asString());
			strcpy(item.CYCLE_LOWER_TYPE,m_qry->field("CYCLE_LOWER_TYPE").asString());
			strcpy(item.BANK_ACCT,m_qry->field("BANK_ACCT").asString());
			strcpy(item.STATE,m_qry->field("STATE").asString());
			strcpy(item.STATE_DATE,m_qry->field("STATE_DATE").asString());
			item.ACCT_ID=m_qry->field("ACCT_ID").asLong();
			item.SERV_ID=m_qry->field("SERV_ID").asLong();
			item.ITEM_GROUP_ID=m_qry->field("ITEM_GROUP_ID").asLong();
		return true;
		}
		catch (TOCIException &oe) {
			cout<<"Error occured ... in TBL_ACCT_BALANCE_CLASS.cpp"<<endl;
			cout<<oe.getErrMsg()<<endl;
			cout<<oe.getErrSrc()<<endl;
			throw oe;
		}
}
TSegment TSegment::Slide(EMoveOperations direction) const {
    Coords::THexPoint hexPos = Coords::ToHex(Position);

    switch (direction) {
        case EMoveOperations::SLIDE_EAST: {
            ++hexPos.X;
            --hexPos.Z;
            break;
        }
        case EMoveOperations::SLIDE_WEST: {
            --hexPos.X;
            ++hexPos.Z;
            break;
        }
        case EMoveOperations::SLIDE_SOUTHEAST: {
            --hexPos.Z;
            ++hexPos.Y;
            break;
        }
        case EMoveOperations::SLIDE_SOUTHWEST: {
            --hexPos.X;
            ++hexPos.Y;
            break;
        }
        default: {
            throw TException("Invalid slide operation recieved in ")
                << __FILE__ << ":" << __LINE__;
        }
    }

    Coords::TColRowPoint newPos = Coords::FromHex(hexPos);
    return TSegment(newPos);
}
Exemplo n.º 20
0
//*=================================================================================
//*原型: void TServer::CheckOSVersion()
//*功能: 检测操作系统版本
//*参数: 无
//*返回: 无
//*说明: 由于采用了Service, 所以只能在NT4及以上版本中运行.
//       如果要在Win9X环境下运行, 必须在RunServer()中去掉CheckOSVersion()调用, 
//       并且不能作为服务器运行, 只能用无窗口的模式运行. 
//*=================================================================================
void TServer::CheckOSVersion()
{
	OSVERSIONINFO   VerInfo;

	ZeroMemory(&VerInfo, sizeof(VerInfo));

	VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);

	if( !GetVersionEx(&VerInfo) )
		throw TException(GetLastError());

	if( VerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT )
	{
		throw TException("本软件仅能在Windows 2000以及以上版本中运行!");
	}
}
Exemplo n.º 21
0
void loadControllerData(const TFilePath &fp, ControllerData &data)
{
	Tifstream is(fp);
	if (!is || !is.good()) {
		throw TException(
			L"Unable to get Farm Controller Data (looking for '" + fp.getWideString() + L"')");
	}

	while (!is.eof()) {
		char line[1024];
		is.getline(line, 1024);

		if (line[0] != '#' && QString(line) != "") {
			std::istrstream iss(line);

			char hostName[512];
			char ipAddr[80];
			int port;

			iss >> hostName >> ipAddr >> port;

			data.m_hostName = hostName;
			data.m_ipAddress = ipAddr;
			data.m_port = port;
			break;
		}
	}
Exemplo n.º 22
0
bool	TBL_ACCT_ITEM_CLASS::Next()
{
		if ( m_qry == NULL)
			throw TException("mqry not open!");
		try{
			if ( !m_qry->next())
				return false;
			item.ACCT_ITEM_ID=m_qry->field("ACCT_ITEM_ID").asLong();
			item.ITEM_SOURCE_ID=m_qry->field("ITEM_SOURCE_ID").asLong();
			item.BILL_ID=m_qry->field("BILL_ID").asLong();
			item.ACCT_ITEM_TYPE_ID=m_qry->field("ACCT_ITEM_TYPE_ID").asLong();
			item.BILLING_CYCLE_ID=m_qry->field("BILLING_CYCLE_ID").asLong();
			item.ACCT_ID=m_qry->field("ACCT_ID").asLong();
			item.SERV_ID=m_qry->field("SERV_ID").asLong();
			item.AMOUNT=m_qry->field("AMOUNT").asLong();
			strcpy(item.CREATED_DATE,m_qry->field("CREATED_DATE").asString());
			item.FEE_CYCLE_ID=m_qry->field("FEE_CYCLE_ID").asLong();
			item.PAYMENT_METHOD=m_qry->field("PAYMENT_METHOD").asLong();
			strcpy(item.STATE,m_qry->field("STATE").asString());
			strcpy(item.STATE_DATE,m_qry->field("STATE_DATE").asString());
			strcpy(item.INV_OFFER,m_qry->field("INV_OFFER").asString());
		return true;
		}
		catch (TOCIException &oe) {
			cout<<"Error occured ... in TBL_ACCT_ITEM_CLASS.cpp"<<endl;
			cout<<oe.getErrMsg()<<endl;
			cout<<oe.getErrSrc()<<endl;
			throw oe;
		}
}
Exemplo n.º 23
0
//---------------------------------------------------------------------------
int TGLM::execute(my_string* passedParams, int numPassedParams){
	//read params from input --> first two are filenames
	for(int i=0;i<numParams;++i){
		P.element(i)=passedParams[i+2].toDouble();
	}

	//write header to output file
	ofstream out;
	out.open(outputFilename.c_str());
	if(!out) throw TException("INTERNALGLM program: the output file '"+outputFilename+"' could not be opened!", _FATAL_ERROR);
	out << "Stat_1";
	for(int i=1;i<numStats;++i){
		out << "\t" << "Stat_" << i+1;
	}
	out << endl;

	for(int i=0;i<numStats;++i) e.element(i)=NormalRandom(0,1);
	e=A*e;

	//compute stats
	s=C*P+c0+e;

	//write stats
	for(int i=0;i<numStats;++i){
		out << s.element(i);
	}
	out << endl;
	out.close();
	return 1;
}
Exemplo n.º 24
0
void readInt( TCfg& cfg, const char *name, int &val ) throw (TException) {
	const char *s;
	char *rest;
	//try {
	s = cfg.getValue( name );
	//} catch( TRequestExc &e ) {
	//	sprintf( msg, "в конфигурационном файле отсутствует параметр %s", name );
	//	logfile->error(msg);
	//	sprintf( msg, "сообщение класса: %s", e.text() );
	//	logfile->error(msg);
	//	throw;
	//}
	//sprintf( msg, "%s = %s", name, s );
	//logfile->debug(msg);
	long a = strtol( s, &rest, 10 );
	while( isspace(*rest) )
		rest++;
	if( *rest != 0 ) {
		sprintf( msg, "Параметр %s должен быть целым числом. Его значение %s", name, s );
		throw TException( 1, msg );
		//logfile->error(msg);
		//sprintf( msg, "его значение %s", s );
		//logfile->error(msg);
		//return 1;
	}
	val = a;
	return;
}
Exemplo n.º 25
0
bool StatAcctItem::GetRecordFromTable(POINT_TYPE &BreakPoint)
{
    char sTemp[200];
    if ( !pRead) {
        sprintf(sTemp,"[%s:%d] GetRecordFromTable 游标还没打开!",_FILE_NAME_,__LINE__);
        throw TException(sTemp);
    }

    if ( ! pRead->Next()) {
        return false;
    }

    BreakPoint=pRead->Get_ACCT_ITEM_ID();



    if (interface.getServ(serv,pRead->Get_SERV_ID(),pRead->Get_CREATED_DATE()) ) {
        pServ=&serv;
        pservinfo=serv.getServInfo();
        pcustinfo=serv.getCustInfo();
    }
    else {
        pServ=NULL;
        pservinfo=NULL;
        pcustinfo=NULL;
    }

    return true;
}
Exemplo n.º 26
0
void readFlg( TCfg& cfg, const char *name, int& flag ) throw (TException) {
	const char *s;
	//try {
	  
	s = cfg.getValue( name );
	//} catch( TRequestExc &e ) {
	//	sprintf( msg, "в конфигурационном файле отсутствует параметр %s", name );
	//	logfile->error(msg);
	//	sprintf( msg, "сообщение класса:%s", e.text() );
	//	logfile->error(msg);
	//	throw;
	//}
	//sprintf( msg, "%s = %s", name, s );
	//logfile->debug(msg);

	if( s[0] == 0 || ( s[0] == '0' && s[1] == 0 ) ) {
		flag = 0;
		return;
	}
	if( s[0] == '1' && s[1] == 0 ) {
		flag = 1;
		return;
	}

	sprintf( msg, "Параметр %s должен быть 0, 1 или пустым. Его значение %s", name, s );
	throw TException( 1, msg );
	//logfile->error(msg);
	//sprintf( msg, "Его значение %s", s );
	//logfile->error(msg);
	//return 1;
}
Exemplo n.º 27
0
bool	TBL_A_REFUND_LOG_CLASS::Next()
{
		if ( m_qry == NULL)
			throw TException("mqry not open!");
		try{
			if ( !m_qry->next())
				return false;
			item.REFUND_LOG_ID=m_qry->field("REFUND_LOG_ID").asLong();
			item.STAFF_ID=m_qry->field("STAFF_ID").asLong();
			strcpy(item.REFUND_REASON,m_qry->field("REFUND_REASON").asString());
			item.CHARGE=m_qry->field("CHARGE").asLong();
			strcpy(item.CREATED_DATE,m_qry->field("CREATED_DATE").asString());
			item.ACCT_ID=m_qry->field("ACCT_ID").asLong();
			item.SERV_ID=m_qry->field("SERV_ID").asLong();
			item.OPER_PAYOUT_ID=m_qry->field("OPER_PAYOUT_ID").asLong();
			strcpy(item.STATE,m_qry->field("STATE").asString());
			item.OLD_REFUND_LOG_ID=m_qry->field("OLD_REFUND_LOG_ID").asLong();
			item.A_REFUNDS_APPLY_ID=m_qry->field("A_REFUNDS_APPLY_ID").asLong();
		return true;
		}
		catch (TOCIException &oe) {
			cout<<"Error occured ... in TBL_A_REFUND_LOG_CLASS.cpp"<<endl;
			cout<<oe.getErrMsg()<<endl;
			cout<<oe.getErrSrc()<<endl;
			throw oe;
		}
}
//*=================================================================================
//*原型: void TSmartOutThread::Initialized(TSmartServer& Server)
//*功能: 初始化数据分发线程
//*参数: Server -- 服务器
//*返回: 无
//*说明: 无
//*=================================================================================
void TSmartOutThread::Initialized(int nPort, TSmartServer *pServer)
{
	m_pServer = pServer ;
	m_nPort = nPort ;

	//通知端口使用UDP
	m_hNotifySocket = socket(AF_INET, SOCK_DGRAM, 0);
	if( m_hNotifySocket == INVALID_SOCKET )
	{
		throw TException("创建UDP套接字失败!", (DWORD)WSAGetLastError());
	}

	//接收请求使用TCP
	m_hServerSocket = socket(AF_INET, SOCK_STREAM, 0);
	if( m_hServerSocket == INVALID_SOCKET )
	{
		CloseOutSocket();
		throw TException("创建TCP套接字失败!", (DWORD)WSAGetLastError());
	}

	int nAnsy = 1 ;
	if( ioctlsocket(m_hServerSocket, FIONBIO, (DWORD*)&nAnsy) == SOCKET_ERROR )
	{
		CloseOutSocket();
		throw TException("设置TCP属性失败!", (DWORD)WSAGetLastError());
	}

	SOCKADDR_IN  sockAddr;

	ZeroMemory(&sockAddr, sizeof(sockAddr));

	sockAddr.sin_family = AF_INET ;
	sockAddr.sin_port = htons(nPort);
	sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);

	if( bind(m_hServerSocket, (SOCKADDR*)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR )
	{
		CloseOutSocket();
		throw TException("不能邦定TCP口!", (DWORD)WSAGetLastError());
	}

	if( listen(m_hServerSocket, 5) == SOCKET_ERROR )
	{
		CloseOutSocket();
		throw TException("TCP不能Listen!", (DWORD)WSAGetLastError());
	}
}
Exemplo n.º 29
0
//*=================================================================================
//*原型: void TServer::InstallService(LPCTSTR pszServiceName, LPCTSTR pszDisplayName)
//*功能: 安装一个服务
//*参数: pszServiceName -- 服务名称
//*      pszDisplayName -- 显示名称
//*返回: 无
//*说明: WINNT服务器基类
//*=================================================================================
void TServer::InstallService(LPCTSTR pszServiceName, LPCTSTR pszDisplayName)
{
	SC_HANDLE  schSCManager;

	schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
	if( schSCManager == NULL )
	{
		throw TException("Call OpenSCManager() Faild!", 
				GetLastError());
	}

	TCHAR  szModuleName[MAX_PATH];
	if( !GetModuleFileName(NULL, szModuleName, MAX_PATH) )
	{
	    CloseServiceHandle(schSCManager);
		throw TException("Call GetModuleFileName() Faild!", 
				GetLastError());
	}

    SC_HANDLE schService = CreateService( 
					schSCManager,              // SCManager database 
					pszServiceName,              // name of service 
					pszDisplayName,           // service name to display 
					SERVICE_ALL_ACCESS,        // desired access 
					SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS , // service type 
					SERVICE_DEMAND_START,      // start type 
					SERVICE_ERROR_NORMAL,      // error control type 
					szModuleName,			   // service's binary 
					NULL,                      // no load ordering group 
					NULL,                      // no tag identifier 
					NULL,                      // no dependencies 
					NULL,                      // LocalSystem account 
					NULL);                     // no password 
	if( schService == NULL )
	{
	    CloseServiceHandle(schSCManager);
		throw TException("本服务器已安装, 不需要再安装!");
	}
	else
	{
		wsprintf(szModuleName, "安装服务%s成功!", m_pszServiceName);
		MessageBox(NULL, szModuleName, SERVICE_TITLE, MB_OK|MB_ICONINFORMATION);
	}

    CloseServiceHandle(schService); 
    CloseServiceHandle(schSCManager); 
}
Exemplo n.º 30
0
void	TBL_STAFF_CLASS::ClearBuf(void)
{
		item.ClearBuf();
		iCurPos=0;
		if (a_item==NULL)
			 throw TException("buffer is empty,please malloc buffer!");
		memset(a_item,0, sizeof(item)*iBufferSize);
}