private bool LoadInstructionReport() { bool vRet = false; //if (CheckPrinterOnline(out_PrinterName)) // { string strSQL = "select t.*" + " from rpt.VIEW_LOADING_INTRODUCTION_TM t " + " where t.LOAD_HEADER_NO=" + LoadHeader_NO; DataSet vDataset = null; vDataset = new DataSet(); DataTable dt; try { if (fMain.OraDb.OpenDyns(strSQL, "VIEW_LOADING_INTRODUCTION_TM", ref vDataset)) { dt = vDataset.Tables["VIEW_LOADING_INTRODUCTION_TM"]; ReportDocument cr = new ReportDocument(); if (dt != null && dt.Rows.Count != 0) { string reportPath = fMain.App_Path + "\\Report File\\" + out_ReportPath; if (!File.Exists(reportPath)) { fMain.AddListBox = "The specified report does not exist \n"; } cr.Load(reportPath); //cr.SetDataSource(dt); cr.Database.Tables["VIEW_LOADING_INTRODUCTION_TM"].SetDataSource((DataTable)dt); //cr.SetParameterValue(out_Parametername, LoadHeader_NO); cr.SetParameterValue(out_Parametername, LoadHeader_NO); cr.PrintOptions.PrinterName = out_PrinterName; cr.PrintToPrinter(1, false, 0, 0); cr.Dispose(); Thread.Sleep(100); RaiseEvents("PRINT INSTRUCTION REPORT LOADING NUMBER: " + LoadHeader_NO); vRet = true; } } Thread.Sleep(100); } catch (Exception exp) { fMain.LogFile.WriteErrLog("[Print Instruction, Load data report] " + exp.Message); PrintInstructionStepProcess = _PrintInstructionStepProcess.InitialReport; } vDataset = null; dt = null; // } return(vRet); }
private void RunProcess() { thrRunning = true; thrShutdown = false; PrintInstructionStepProcess = _PrintInstructionStepProcess.InitialReport; chkResponse = DateTime.Now; while (thrRunning) { try { if (thrShutdown) { return; } switch (PrintInstructionStepProcess) { case _PrintInstructionStepProcess.InitialReport: if (GetConfigReport()) { PrintInstructionStepProcess = _PrintInstructionStepProcess.CheckStatusReport; } break; case _PrintInstructionStepProcess.CheckStatusReport: if (CheckStatusInstructionReport()) { PrintInstructionStepProcess = _PrintInstructionStepProcess.LoadReport; } break; case _PrintInstructionStepProcess.LoadReport: if (LoadInstructionReport()) { UpdateInstructionToDatabase(LoadHeader_NO); PrintInstructionStepProcess = _PrintInstructionStepProcess.ChangeProcess; } else { PrintInstructionStepProcess = _PrintInstructionStepProcess.CheckStatusReport; } break; case _PrintInstructionStepProcess.UpdateStatus: // UpdateInstructionToDatabase(LoadHeader_NO); PrintInstructionStepProcess = _PrintInstructionStepProcess.ChangeProcess;; break; case _PrintInstructionStepProcess.ChangeProcess: PrintInstructionStepProcess = _PrintInstructionStepProcess.CheckStatusReport; break; } Thread.Sleep(1000); } catch (Exception exp) { RaiseEvents(exp.Message + "[source>" + exp.Source + "]"); Thread.Sleep(3000); } //finally //{ // mShutdown = true; // mRunning = false; //} Thread.Sleep(500); } }