logical pc_TopicFromOldStyle :: Setup_SDB_Structure ( ) { PropertyHandle ref_dsc_class(GetDBHandle(),"ODS_Class",PI_Read); logical term = NO; BEGINSEQ if ( !ref_dsc_class.Get(ExtractKey()) ) LEAVESEQ Setup_SDB_Resource(&ref_dsc_class); pc_TopicFromOldStyle smcebase(GPH("smcebase")); smcebase.Setup_collection(ref_dsc_class.GPH("bas_descriptions")); pc_TopicFromOldStyle smcepdde(GPH("smcepdde")); smcepdde.Setup_collection(ref_dsc_class.GPH("atr_descriptions")); pc_TopicFromOldStyle smcepref(GPH("smcepref")); smcepref.Setup_collection(ref_dsc_class.GPH("ref_descriptions")); pc_TopicFromOldStyle smcershp(GPH("smcershp")); smcershp.Setup_collection(ref_dsc_class.GPH("rsp_descriptions")); pc_TopicFromOldStyle smcepsmc(GPH("smcepsmc")); smcepsmc.Setup_collection(ref_dsc_class.GPH("sor_descriptions")); ENDSEQ return(term); }
void CloseAllDB(void) /* Closes all open DB handles */ { CF_DB *dbp = NULL; int i = 0; Debug("CloseAllDB()\n"); while (true) { if (!GetDBHandle(&dbp)) { FatalError("CloseAllDB: Could not pop next DB handle"); } if (dbp == NULL) { break; } if (!CloseDB(dbp)) { CfOut(cf_error, "", "!! CloseAllDB: Could not close DB with this handle"); } i++; } Debug("Closed %d open DB handles\n", i); }
char *pc0_ImportProtokoll :: GetImportFolder (NString &nstring ) { return ( ::GetImportFolder(nstring,GetDBHandle(),"XMLActions/") ); }
logical pc_TopicFromOldStyle :: Setup_ODC_PFunction (PropertyHandle *prophdl ) { PropertyHandle *imp_parms = prophdl->GPH("imp_parms"); PropertyHandle *retval = prophdl->GPH("retval"); PropertyHandle *retval_name = GPH("retval_name"); int32 indx0 = 0; logical term = NO; BEGINSEQ if ( Setup_SDB_Resource(prophdl) ) ERROR *GPH("action") = *prophdl->GPH("action"); pc_TopicFromOldStyle implementations(GPH("implementations")); while ( implementations.Get(indx0++) ) if ( imp_parms->Get(implementations.ExtractKey()) ) implementations.Setup_ODC_FunctImp(imp_parms); if ( *retval_name->GetString() && retval->Get(FIRST_INSTANCE) && *retval_name == *retval->GPH("sys_ident") ) { PropertyHandle var_ph(GetDBHandle(),"ODC_Variable",PI_Write); pc_TopicFromOldStyle variables(&var_ph); if ( variables.Get(*retval_name) ) variables.Setup_SDB_Resource(retval); } Save(); RECOVER term = YES; ENDSEQ return(term); }
char *pc_ODC_Variable :: DataTypeCString (NString &nstring ) { PropertyHandle *ddetype = GPH("ddetype"); char *save_type = NULL; logical term = NO; BEGINSEQ if ( GPH("const_val")->IsTrue() ) { nstring += "const"; nstring.Append(' '); } if ( TestSysVariable("C_INTERFACE","Y") ) { PropertyHandle inst_coll(GetDBHandle(),"InstCollection",PI_Read); SDBCERR PropertyHandle phCInterface("CInterface"); if ( !inst_coll(phCInterface) ) SDBERR(99) if ( inst_coll.GPH("collection")->Get(*ddetype) ) { save_type = strdup(ddetype->GetString()); ddetype->SetValue("void",NO); } }
//*======================================================================================== //*函数: bool CSmartJZSRCTable::SvaeToDB(CString strSQL) //*功能: 保存到数据库 //*参数: 略 //*返回: 成功与否 //*说明: 虚基类程序 //*======================================================================================== bool CSmartJZSRCTable::SaveToDB(CString strSQL1, CString strSQL2) { long nDatabase = GetDBHandle(DATABASE_NORMAL); if( nDatabase <= 0 ) { ReportLog(RET_DBBUSY, "保存扎帐数据", "不能得到数据库句柄!"); return false; } // printf("%s\n", strSQL1.GetBuffer(0)); long nRec = ExecuteSQL(nDatabase, strSQL1.GetBuffer(0)); if( nRec != RET_OK ) { printf("%s\n", strSQL1.GetBuffer(0)); CString strText; strText = "create table " + m_strTableName ; strText += "(smt_rowid integer not null primary key,smt_authno number(10,0) not null,"; strText += "smt_data varchar(100) not null,smt_CRC number(2) , smt_datetime date ,"; strText += "smt_dealwith number(2),smt_dealwithdatetime date,smt_adjustcode varchar(4)) "; ExecuteSQL(nDatabase, strText.GetBuffer(0)); strText = "create sequence " + m_strTableName + "_rowid start with 1 increment by 1"; ExecuteSQL(nDatabase, strText.GetBuffer(0)); if( ExecuteSQL(nDatabase, strSQL1.GetBuffer(0)) != RET_OK ) { FreeDBHandle(nDatabase); return false; } } // printf("%s\n", strSQL2.GetBuffer(0)); nRec = ExecuteSQL(nDatabase, strSQL2.GetBuffer(0)); if( nRec != RET_OK ) { printf("%s\n", strSQL2.GetBuffer(0)); FreeDBHandle(nDatabase); return false; } if( m_bUpdate ) { nRec = ExecuteSQL(nDatabase, strUpdate.GetBuffer(0)); if( nRec != RET_OK ) { printf("%s\n", strUpdate.GetBuffer(0)); FreeDBHandle(nDatabase); return false; } } FreeDBHandle(nDatabase); return true; }
logical pc0_ImportProtokoll :: ImportOpenXMLActions ( ) { TP_ImportGlobals imp_globals(GetDBHandle()); int32 indx0 = 0; logical term = NO; while ( Get(indx0++) ) if ( *GPH("status") == "IMPORT_initialisiert" ) if ( ImportXMLActions(&imp_globals) ) term = YES; return(term); }
logical pc0_ImportProtokoll :: ImportXMLActions (TP_ImportGlobals *imp_globals ) { DataSourceHandle xml_datasource; NString cpath; dttm datetime; char *ori_kennung = GetSysVariable("EIGENTUEMER_KENNUNG"); int16 ori_dateformat = dfs::GetDateFormat(); logical del_globals = imp_globals ? NO : YES; logical term = NO; ODABAClient tmpoclient; WriteMessages("Start",NO); SetSysVariable("EIGENTUEMER_KENNUNG","P"); SetStatus(IMPORT_gestartet,YES); dfs::ChangeDate(DFS_YYMMDD_point); if ( !imp_globals ) imp_globals = new TP_ImportGlobals(GetDBHandle()); else imp_globals->Clear(); GetImportFolder(cpath); cpath += GetString("xml_file_name"); SetSysVariable("XML_FILE",cpath); if ( xml_datasource.Open(tmpoclient,"XMLImport") ) { imp_globals->Message("Import-Datei konnte nicht geöffner werden"); SetStatus(IMPORT_fehlerhaft_beendet,NO); } else { ImportXMLActions(imp_globals->get_vs_hr() ,xml_datasource.dbhandle,"HRAction",imp_globals); ImportXMLActions(imp_globals->get_vs_rs() ,xml_datasource.dbhandle,"RSAction",imp_globals); ImportXMLActions(imp_globals->get_vs_un() ,xml_datasource.dbhandle,"UNAction",imp_globals); ImportXMLActions(imp_globals->get_vs_phv(),xml_datasource.dbhandle,"PHVAction",imp_globals); ImportXMLActions(imp_globals->get_vs_hhv(),xml_datasource.dbhandle,"HHVAction",imp_globals); ImportXMLActions(imp_globals->get_vs_rhv(),xml_datasource.dbhandle,"RHVAction",imp_globals); ImportXMLActions(imp_globals->get_vs_whg(),xml_datasource.dbhandle,"WHGAction",imp_globals); ImportXMLActions(imp_globals->get_vs_kfz(),xml_datasource.dbhandle,"KFZAction",imp_globals); } dfs::ChangeDate(ori_dateformat); WriteMessages(imp_globals->GetMessages(),NO); WriteMessages("Stop",NO); datetime.SetCurrent(); *GPH("terminated") = datetime; SetStatus(IMPORT_erfolgreich_beendet,NO); if ( del_globals ) delete imp_globals; SetSysVariable("EIGENTUEMER_KENNUNG",ori_kennung ? ori_kennung : ""); return(term); }
logical pc_TopicFromOldStyle :: Setup_SDB_ValueList ( ) { PropertyHandle ref_dsc_class(GetDBHandle(),"ODS_Class",PI_Read); PropertyHandle sys_ident(GPH("sys_ident")); PropertyHandle V8("V8"); PropertyHandle sv; int32 indx0 = 0; logical term = NO; BEGINSEQ if ( !ref_dsc_class.Get(ExtractKey()) ) LEAVESEQ DBObjectHandle dbh(GetDBHandle()); PropertyHandle vl(dbh,"SDB_ValueList",PI_Write); sv = sys_ident + V8; if ( !vl.Provide(sv) ) ERROR pc_TopicFromOldStyle vlist(&vl); Setup_SDB_Resource(&ref_dsc_class); PH(&vl,values) pc_TopicFromOldStyle pc_values(&values); PH(&ref_dsc_class,val_descriptions); if ( !dict.IsValid() ) dict.Open(GetDBHandle()); PropertyHandle cs(dict,sys_ident.GetString(),PI_Read); while ( cs.Get(indx0++) ) { values.Add(*cs.GPH("string")); *values.GPH("__AUTOIDENT") = cs.GPH("value"); *values.GPH("type") = cs.GPH("type"); if ( val_descriptions.Get(*values.GPH("sys_ident")) ) pc_values.Setup_SDB_Resource(&val_descriptions); } RECOVER term = YES; ENDSEQ return(term); }
logical pcBase :: RemoveFromSpecialExtent (char *extnames ) { char *cur_extent = GetExtentName(); logical term = NO; BEGINSEQ if ( !cur_extent || !extnames ) LEAVESEQ if ( !Exist() ) ERROR if ( strcmp(cur_extent,extnames) ) { PropertyHandle extent(GetDBHandle(),extnames,PI_Write); SDBCERR if ( extent.Get(ExtractKey()) ) extent.Delete(); } else
logical pc_TopicFromOldStyle :: Setup_ODC_ImpClass ( ) { PropertyHandle ref_dsc_class(GetDBHandle(),"ODS_Class",PI_Read); PropertyHandle *fct_descriptions = ref_dsc_class.GPH("fct_descriptions"); int32 indx0 = 0; logical term = NO; BEGINSEQ if ( !ref_dsc_class.Get(ExtractKey()) ) LEAVESEQ if ( Setup_SDB_Structure() ) ERROR pc_TopicFromOldStyle pfunctions(GPH("pfunctions")); while ( pfunctions.Get(indx0++) ) if ( fct_descriptions->Get(pfunctions.ExtractKey()) ) pfunctions.Setup_ODC_PFunction(fct_descriptions); RECOVER term = YES; ENDSEQ return(term); }
logical pcBase :: ProvideInSpecialExtent (char *extnames ) { char *cur_extent = GetExtentName(); logical term = NO; BEGINSEQ if ( !cur_extent || !extnames ) LEAVESEQ if ( !Exist() ) ERROR if ( strcmp(cur_extent,extnames) ) { PropertyHandle extent(GetDBHandle(),extnames,PI_Write); SDBCERR // waere besser, aber der vertraegt weak-typed nicht // extent.Provide(ExtractKey()); SDBCERR if ( !extent.Get(ExtractKey()) ) extent.AddReference(*this); SDBCERR } RECOVER term = YES; ENDSEQ return(term); }
long CHistoryData::IdentifyDataProcess(TSSmartDocEx *pDocEx, TSSmartTask *pTask, TSCmdBuffer *pBuffer,unsigned char *RawData,int nPortNoc) { unsigned char ucRawData[256]; int nPortNo,nFlowNo; CSmartSRCJSBTable SRCTable; nPortNo = pDocEx->nPortNo; int iBegin=-2, iEnd = -2; GetNumberRange(pTask->szMemo, iBegin, iEnd); if( pBuffer == NULL ) { TSSmartDoc *pDoc = pDocEx->pChildDoc[pDocEx->nPortNo]; CString strString; if( OutputRealData(pTask, pDocEx->pChildDoc[pDocEx->nPortNo], 0x09, (unsigned char*)pDoc->m_szDeviceID, iBegin) != RET_OK ) { ReportLog(pDocEx->pChildDoc[pDocEx->nPortNo], pTask, RET_TERME_NOANSWER, "历史任务", "金仕达中间传输层无反应!"); } char szTemp[18]; strString.Format("AuthNo = %d, 收序号为%d的数据时终端无反应", pDocEx->pChildDoc[pDocEx->nPortNo]->m_nAuthID, iBegin); printf("%s\n", strString); if( iBegin == iEnd ) { pDoc->m_nFlowFlag = 0 ; TerminateTask(); } else { if( iBegin == 65535 ) iBegin = 0 ; else iBegin++; sprintf(szTemp, "%d:%d", iBegin, iEnd); strcpy(pTask->szMemo, szTemp); } ReportLog(pDoc, pTask, RET_OK, "历史任务", ""); return RET_OK; } memcpy(ucRawData,&pBuffer->pBuffer[4],pBuffer->pBuffer[3]); printf("History, IdentifyDataProcess.............\n"); if( pBuffer->pBuffer[3] == 0x00 ) { TSSmartDoc *pDoc = pDocEx->pChildDoc[pDocEx->nPortNo]; CString strString; long nDatabase = GetDBHandle(DATABASE_NORMAL); if( OutputRealData(pTask, pDocEx->pChildDoc[pDocEx->nPortNo], 0x08, (unsigned char*)pDoc->m_szDeviceID, iBegin) != RET_OK ) { ReportLog(pDocEx->pChildDoc[pDocEx->nPortNo], pTask, RET_TERME_NOANSWER, "历史任务", "金仕达中间传输层无反应!"); } char szTemp[18]; strString.Format("无对应的序号为%d的数据!!", iBegin); printf("%s\n", strString); if( iBegin == iEnd ) { pDoc->m_nFlowFlag = 0 ; TerminateTask(); } else { if( iBegin == 65535 ) iBegin = 0 ; else iBegin++; sprintf(szTemp, "%d:%d", iBegin, iEnd); strcpy(pTask->szMemo, szTemp); } ReportLog(pDoc, pTask, RET_OK, "历史任务", ""); return RET_OK; } //CRC检测 if( !CRCValid(ucRawData) ) { ReportLog(pDocEx, pTask, RET_DBQUERYERROR, "历史任务", "CRC校验错!"); } nFlowNo = ucRawData[6]*256+ucRawData[7]; if( nFlowNo == iBegin ) { if( OutputRealData(pTask, pDocEx->pChildDoc[pDocEx->nPortNo], 0x22, (unsigned char*)ucRawData, 256) != RET_OK ) { ReportLog(pDocEx->pChildDoc[pDocEx->nPortNo], pTask, RET_TERME_NOANSWER, "历史任务", "金仕达中间传输层无反应!"); } if( iBegin == iEnd ) { pDocEx->pChildDoc[pDocEx->nPortNo]->m_nFlowFlag = 0 ; TerminateTask(); } else { if( iBegin == 65535 ) iBegin = 0 ; else iBegin++; char szTemp[18]; sprintf(szTemp, "%d:%d", iBegin, iEnd); strcpy(pTask->szMemo, szTemp); } } else { if( OutputRealData(pTask, pDocEx->pChildDoc[pDocEx->nPortNo], 0x22, (unsigned char*)ucRawData, 256) != RET_OK ) { ReportLog(pDocEx->pChildDoc[pDocEx->nPortNo], pTask, RET_TERME_NOANSWER, "历史任务", "金仕达中间传输层无反应!"); } if( iBegin == iEnd ) { pDocEx->pChildDoc[pDocEx->nPortNo]->m_nFlowFlag = 0 ; TerminateTask(); } else { if( iBegin == 65535 ) iBegin = 0 ; else iBegin++; char szTemp[18]; sprintf(szTemp, "%d:%d", iBegin, iEnd); strcpy(pTask->szMemo, szTemp); } } return RET_OK; }