void Sphere_ExitServer() { // Trigger server quit g_Serv.r_Call("f_onserver_exit", &g_Serv, NULL); g_Serv.SetServerMode(SERVMODE_Exiting); #ifndef _MTNETWORK g_NetworkOut.waitForClose(); #else g_NetworkManager.stop(); #endif g_Main.waitForClose(); g_PingServer.waitForClose(); g_asyncHdb.waitForClose(); #if !defined(_WIN32) || defined(_LIBEV) if ( g_Cfg.m_fUseAsyncNetwork != 0 ) g_NetworkEvent.waitForClose(); #endif g_Serv.SocketsClose(); g_World.Close(); LPCTSTR Reason; switch ( g_Serv.m_iExitFlag ) { case -10: Reason = "Unexpected error occurred"; break; case -9: Reason = "Failed to bind server IP/port"; break; case -8: Reason = "Failed to load worldsave files"; break; case -3: Reason = "Failed to load server settings"; break; case -1: Reason = "Shutdown via commandline"; break; #ifdef _WIN32 case 1: Reason = "X command on console"; break; #else case 1: Reason = "Terminal closed by SIGHUP signal"; break; #endif case 2: Reason = "SHUTDOWN command executed"; break; case 4: Reason = "Service shutdown"; break; case 5: Reason = "Console window closed"; break; case 6: Reason = "Proccess aborted by SIGABRT signal"; break; default: Reason = "Server shutdown complete"; break; } g_Log.Event(LOGM_INIT|LOGL_FATAL, "Server terminated: %s (code %d)\n", Reason, g_Serv.m_iExitFlag); g_Log.Close(); }
void GravadorControllerDlg::OnBnClickedGravar() { // manda gravar todos as placas que estiverem na mesma interface. // se for para tentar de novo nao carrega nada BOOL bRet; bRet = FALSE; if (currentPos == 0) currentPos = adm.ReturnNextPosition(¤tPos); do { if (currentPos != 0) { bRet = GravacaoIndividual((currentPos-1)); if (!bRet) break; ControlaLeds(currentPos-1, ldVERDE); currentPos = adm.ReturnNextPosition(¤tPos); } } while (currentPos != 0); CString cS; if (bRet) { nContOk++; cS.Format(_T("%d"), nContOk); m_sTestados.SetWindowText(cS); SetLed(ledVERDE_OK); } else { ControlaLeds(currentPos-1, ldVERMELHO); SetLed(ledVERMELHO); } int nPos; nPos = 0; nPos = adm.ReturnNextPosition(&nPos); if ( (bRet) || (pGravador[nPos-1]->IsTestFct()) ) adm.AtualizaDadosPrn(&dadosImpressora); if (bRet) { if ( (nPos > 0) && (pGravador[nPos-1]->IsTestFct() || (!pGravador[nPos-1]->IsUsoFct())) ) impressora.ImprimeEtiqueta(TRUE, &dadosImpressora); else impressora.ImprimeEtiqueta(TRUE, &dadosImpressora, TRUE); BOOL bFim; adm.AtualizaInfo(nContOk, nContErros, &bFim, 0); nTentativas = 0; ProcessaFimDeProducao(bFim); bTentandoDeNovo = FALSE; } else { if ( pGravador[currentPos-1]->IsTestFct() && pGravador[currentPos-1]->IsUsoFct() && (!pGravador[currentPos-1]->GetResultTestFct()) ) { OnPara(); } else { // habilita botão parar e tenta de novo ControlaBotoes(TRUE, TRUE, FALSE); bTentandoDeNovo = TRUE; } } if ( (nPos > 0) && pGravador[nPos-1]->IsUsoFct() && pGravador[nPos-1]->IsTestFct() ) { CLog log; try { log.Open(AFX_DB_USE_DEFAULT_TYPE, NULL, CRecordset::appendOnly); log.AddNew(); log.m_DataHora = CTime::GetCurrentTime(); log.m_SN = dadosImpressora.strEstacao + dadosImpressora.strData + dadosImpressora.strSerie; log.m_SN.Left(13); log.m_Modelo = dadosImpressora.strProduto.Left(12); log.m_Codigo = dadosImpressora.strCodigo.Left(8);; log.m_Soft = dadosImpressora.strVersaoSoft.Left(8); log.m_FCT = pGravador[nPos-1]->GetResultTestFct(); UCHAR buffer[SIZE_LEITURA_FCT/2]; pGravador[nPos-1]->GetFctData(buffer, sizeof(buffer)); log.m_FCT01 = buffer[0]; log.m_FCT02 = buffer[1]; log.m_FCT03 = buffer[2]; log.m_FCT04 = buffer[3]; log.m_FCT05 = buffer[4]; log.m_FCT06 = buffer[5]; log.m_FCT07 = buffer[6]; log.m_FCT08 = buffer[7]; log.m_FCT09 = buffer[8]; log.m_FCT10 = buffer[9]; log.m_FCT11 = buffer[10]; log.m_FCT12 = buffer[11]; log.m_FCT13 = buffer[12]; log.m_FCT14 = buffer[13]; log.m_FCT15 = buffer[14]; log.m_FCT16 = buffer[15]; log.Update(); log.Close(); } catch (CDBException *e) { DebugDboException(e, "Gravando log no banco de dados ", 0); } catch (CMemoryException *e) { CHAR chError[1024]; e->GetErrorMessage(chError, sizeof(chError)); e->Delete(); CString cException; cException = chError; m_debugLog.Log(LOG_ERROR, cException); MessageBox(cException, "ERRO", MB_OK | MB_ICONERROR); } } }