void UEAnalysisOnRootple::MultiAnalysis(char* filelist,char* outname,Float_t weight[7],Float_t eta, Float_t triggerPt,string type,string trigger,string tkpt,Float_t ptCut) { BeginJob(outname); etaRegion = eta; ptThreshold = ptCut/1000.; char RootTupleName[255]; char RootListFileName[255]; strcpy(RootListFileName,filelist); ifstream inFile(RootListFileName); int filenumber = 0; while(inFile.getline(RootTupleName,255)) { if (RootTupleName[0] != '#') { cout<<"I'm analyzing file "<<RootTupleName<<endl; TFile *f = new TFile("UE_softjet_1.root");//RootTupleName); //f->ls(); cout<<"got file\n"; TTree * tree = (TTree*)gDirectory->Get("AnalysisTree"); cout<<"got tree\n"; //tree->ls(); Init(tree); cout<<"got init\n"; //std::cout<< weight[filenumber]<<triggerPt<<type<<trigger<<tkpt << std::endl; cout<< "Looping...\n"; //Loop(weight[filenumber],triggerPt,type,trigger,tkpt); //Loop(1,triggerPt,type,trigger,tkpt); } else { if (RootTupleName[1] == '#') break; } filenumber++; } //EndJob(); }
status_t PrinterDriver::PrintJob(BFile *spoolFile, BMessage *jobMsg) { if (!spoolFile || !fPrinterNode) return B_ERROR; fJobFile = spoolFile; print_file_header pfh; // read print file header fJobFile->Seek(0, SEEK_SET); fJobFile->Read(&pfh, sizeof(pfh)); // read job message BMessage msg; msg.Unflatten(fJobFile); BeginJob(); fPrinting = true; printf("PrinterDriver::PrintJob, print massage read from spool file\n"); jobMsg->PrintToStream(); printf("\nPrinterDriver::PrintJob, print massage passed to print job\n"); msg.PrintToStream(); printf("\n"); for (int32 page = 1; page <= pfh.page_count; ++page) { printf("PrinterDriver::PrintPage(): Faking print of page %" B_PRId32 "/ %" B_PRId32 "\n", page, pfh.page_count); } fJobFile->Seek(0, SEEK_SET); PrintJobReader reader(fJobFile); status_t status = reader.InitCheck(); printf("\nPrintJobReader::InitCheck(): %s\n", status == B_OK ? "B_OK" : "B_ERROR"); printf("PrintJobReader::NumberOfPages(): %" B_PRId32 "\n", reader.NumberOfPages()); printf("PrintJobReader::FirstPage(): %" B_PRId32 "\n", reader.FirstPage()); printf("PrintJobReader::LastPage(): %" B_PRId32 "\n", reader.LastPage()); BRect rect = reader.PaperRect(); printf("PrintJobReader::PaperRect(): BRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f)\n", rect.left, rect.top, rect.right, rect.bottom); rect = reader.PrintableRect(); printf("PrintJobReader::PrintableRect(): BRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f)\n", rect.left, rect.top, rect.right, rect.bottom); int32 xdpi, ydpi; reader.GetResolution(&xdpi, &ydpi); printf("PrintJobReader::GetResolution(): xdpi:%" B_PRId32 ", ydpi:%" B_PRId32 "\n", xdpi, ydpi); printf("PrintJobReader::GetScale(): %.1f\n", reader.GetScale()); fPrinting = false; EndJob(); return status; }
status_t PrinterDriver::PrintJob ( BFile *jobFile, // spool file BNode *printerNode, // printer node, used by OpenTransport() to find & load transport add-on BMessage *jobMsg // job message ) { print_file_header pfh; status_t status; BMessage *msg; int32 page; uint32 copy; uint32 copies; const int32 passes = 2; fJobFile = jobFile; fPrinterNode = printerNode; fJobMsg = jobMsg; if (!fJobFile || !fPrinterNode) return B_ERROR; if (fPrintTransport.Open(fPrinterNode) != B_OK) { return B_ERROR; } if (fPrintTransport.IsPrintToFileCanceled()) { return B_OK; } // read print file header fJobFile->Seek(0, SEEK_SET); fJobFile->Read(&pfh, sizeof(pfh)); // read job message fJobMsg = msg = new BMessage(); msg->Unflatten(fJobFile); // We have to load the settings here for Dano/Zeta because they don't store // all fields from the message returned by config_job in the job file! PrinterSettings::Read(printerNode, msg, PrinterSettings::kJobSettings); if (msg->HasInt32("copies")) { copies = msg->FindInt32("copies"); } else { copies = 1; } // force creation of Report object Report::Instance(); // show status window StatusWindow* statusWindow = new StatusWindow(passes, pfh.page_count, this); status = BeginJob(); fPrinting = true; for (fPass = 0; fPass < passes && status == B_OK && fPrinting; fPass++) { for (copy = 0; copy < copies && status == B_OK && fPrinting; copy++) { for (page = 1; page <= pfh.page_count && status == B_OK && fPrinting; page++) { statusWindow->NextPage(); status = PrintPage(page, pfh.page_count); } // re-read job message for next page fJobFile->Seek(sizeof(pfh), SEEK_SET); msg->Unflatten(fJobFile); } } status_t s = EndJob(); if (status == B_OK) status = s; delete fJobMsg; // close status window if (Report::Instance()->CountItems() != 0) { statusWindow->WaitForClose(); } if (statusWindow->Lock()) { statusWindow->Quit(); } // delete Report object Report::Instance()->Free(); return status; }
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int) { try { GetWindowsVersion(); } catch(Exception * E) { MessageBox(NULL,E->Message.c_str(),"错误",MB_OK | MB_ICONSTOP); return 99; } DateSeparator = '-'; ShortDateFormat = "yyyy-m-d"; try { ProcessExitCode = 0; frmExportToDB = NULL; SlentMode = false; LogFile = NULL; Application->Initialize(); Application->Title = "PowerBill通用话单查询转换系统"; InCmdMode = strlen(lpCmdLine) > 0; FTPTimeout = -1; //分析参数 if(InCmdMode) { AnsiString Parameters(lpCmdLine); AnsiString ListFileName = ""; AnsiString LogFileName = ""; AnsiString TableName = ""; AnsiString DBName = ""; AnsiString BillName = ""; AnsiString TempPath = ""; bool TransFieldValue = false; int MaxError = 0; int pos1 = 1; int pos2 = Parameters.Pos("="); AnsiString ParamName,ParamValue; AnsiString Message; bool VerifyFile = true; int JobMode = 1; AnsiString DirList; AnsiString FTPServer; while(pos2 > 0) { ParamName = LowerCase(Parameters.SubString(pos1,pos2 - 1).Trim()); Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - pos2); if(Parameters.SubString(1,1) == "\"") { Parameters = Parameters.SubString(2,Parameters.Length() - 1); pos2 = Parameters.Pos("\""); if(pos2 < 1) break; ParamValue = Parameters.SubString(1,pos2 - 1); Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - pos2); pos2 = GetNextCharPos(Parameters.c_str()); Parameters = Parameters.SubString(pos2,Parameters.Length() - pos2 + 1); } else { pos2 = Parameters.Pos(" "); if(pos2 < 1) { ParamValue = Parameters.SubString(1,Parameters.Length()); } else { ParamValue = Parameters.SubString(1,pos2 - 1); Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - ParamValue.Length()); pos2 = GetNextCharPos(Parameters.c_str()); Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - pos2); } } if(ParamName == "files") ListFileName = ParamValue; else if(ParamName == "db") DBName = ParamValue; else if(ParamName == "table") TableName = ParamValue; else if(ParamName == "silent") SlentMode = ParamValue == "1" || ParamValue.LowerCase() == "true" || ParamValue.LowerCase() == "yes"; else if(ParamName == "log") LogFileName = ParamValue; else if(ParamName == "maxdberrors") { if(IsNumber(ParamValue.c_str())) MaxError = StrToInt(ParamValue); else Message += "最大错误数无效[" + ParamValue + "];"; } else if(ParamName == "tempdir") { TempPath = ParamValue; } else if(ParamName == "billname") BillName = ParamValue; else if(ParamName == "trans") TransFieldValue = ParamValue == "1" || ParamValue.LowerCase() == "true" || ParamValue.LowerCase() == "yes"; //else if(ParamName == "verifyfile") // VerifyFile = ParamValue == "1" || ParamValue.LowerCase() == "true"; else if(ParamName == "mode") { if(ParamValue == "local") JobMode = 1; else if(ParamValue == "ftp") JobMode = 2; else Message += "指定的工作模式无效[" + ParamValue + "]"; } else if(ParamName == "ftpserver") { FTPServer = ParamValue; } else if(ParamName == "dirlist") { DirList = ParamValue; } else if(ParamName == "timeout") { if(IsNumber(ParamValue.c_str())) FTPTimeout = StrToInt(ParamValue); } else { Message += "无效参数[" + ParamName + "];"; } pos2 = Parameters.Pos("="); } if(Message == "") { if(TableName == "") Message += "没有指定导入数据的目标表;"; if(DBName == "") Message += "没有指定要导入的目标数据库的连接名称;"; if(BillName == "") Message += "没有指定话单格式名称"; if(JobMode == 1) { if(ListFileName == "") Message += "没有指定导入文件列表文本文件;"; if(!FileExists(ListFileName)) Message += "指定的导入文件列表文本文件不存在;"; } else if(JobMode == 2) { if(DirList == "") Message += "没有指定FTP列表文件;"; if(!FileExists(DirList)) Message += "指定的FTP目录列表文本文件不存在;"; if(FTPServer == "") Message += "没有指定FTP服务器名称;"; } } LogFile = fopen(LogFileName.c_str(),"w"); if(LogFile == NULL) { LogFileName = ExtractFilePath(Application->ExeName) + "ibill.log"; LogFile = fopen(LogFileName.c_str(),"w"); if(LogFile == NULL) ExitProcess(3); } if(SlentMode) { AllocConsole(); SetConsoleCtrlHandler(HandlerRoutine,true); } if(Message != "") { ShowErrorMessage(Application->Handle,Message.c_str(),true,2); } BeginJob(JobMode,ListFileName, BillName, DBName, TableName, LogFileName, TempPath, TransFieldValue, MaxError,VerifyFile,FTPServer,DirList,0); fclose(LogFile); if(SlentMode) FreeConsole(); ExitProcess(ProcessExitCode); } else { Application->CreateForm(__classid(TfrmMain), &frmMain); Application->Run(); } } catch (Exception &exception) { //Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { //Application->ShowException(&exception); } } return 0; }
/* Main function */ int main(int argc, char** argv) { if( BeginJob( argc, argv ) == 0 ) { cout<<"BeginJob failed"<<endl; return 0; } /* Layer 1. The main loop over every stream entries */ /* ------------------------------------------------ */ CurrRun.Run = -1; cout<<"StreamChain add "<<StreamChain<<endl; unsigned int entries = StreamChain->GetEntries(); for( unsigned int entry=0; entry<entries; entry++ ) { unsigned int localentry = StreamChain->LoadTree(entry); int ret = Reader->GetEntry( localentry ); if( ret==0 ) { cout<<"Error: Read error"<<endl; return 1; } /* Process run information and possible long time jump */ if( Reader->Run != CurrRun.Run ) { if( CurrRun.Run != -1 ) { /* End Run */ if( EndRun( Reader ) == 0 ) { cout<<"EndRun failed"<<endl; return 0; } } /* Begin Run */ if( BeginRun( Reader ) == 0 ) { cout<<"BeginRun failed"<<endl; return 0; } } /*** Test each entry here ***/ SubEvt* pSubEvt = new SubEvt( Reader ); TimeStamp NewTime( pSubEvt->TrigSec, pSubEvt->TrigNano ); if( (NewTime - CurrRun.CurrTime).GetSeconds() > 120 /* Two minutes */ ) { CurrRun.Breaks.push_back( CurrRun.CurrTime ); CurrRun.Breaks.push_back( NewTime ); CurrRun.SkipTime.Add( (NewTime - CurrRun.CurrTime).GetSeconds() ); } CurrRun.CurrTime = NewTime; /* Cache all temporal related event. Give a chance to clean up the queue and do muon Id */ SubEvtQueue PassedQueue = CachedQueueInsert( NewTime, pSubEvt ); /* Layer 2. The main loop over every non-muon SubEvt */ /* ------------------------------------------------- */ SubEvtQueueIterator it, it_end = PassedQueue.end(); for( it = PassedQueue.begin(); it != it_end; it++ ) { /* Build delay coincident event */ SubEvt* pSubEvt = it->second; int ret = BuildEvent( pSubEvt ); if( ret == 0 ) { cout<<"Error in BuildEvent"<<endl; } delete pSubEvt; } /*** End of SubEvt loop ***/ } /*** End of stream entry loop ***/ if( EndRun( Reader ) == 0 ) { cout<<"EndRun failed"<<endl; return 0; } /* End Job */ /* ------- */ if( EndJob() == 0 ) { cout<<"BeginJob failed"<<endl; return 0; } return 1; }