private RESULT MakingTiff(decimal p_faxId, string p_strTrNo, string p_strPacket, string p_strFaxFormLocal, string p_strFaxFormFullPath, DbModule.SEND_REQUEST_DTL_TMK p_tmkDtlInfo, DbModule.DOC_INFO_ALL_TMK p_docInfo, P_TYPE p_destProcessType) { RESULT result = RESULT.EMPTY; // ADD - KIMCG : 20140903 // 팩스번호 복호화 처리 if (Config.ENCRYPT_FIELD_YN == "Y") { string strDecrytedFaxNo = ""; if (EncryptApi.Decrypt(p_tmkDtlInfo.strFaxNo, out strDecrytedFaxNo)) { p_tmkDtlInfo.strFaxNo = strDecrytedFaxNo; } else { LogWrite(LOG_LEVEL.WRN, "팩스번호 복호화 처리 실패", RESULT.EMPTY); } } // ADD - END if (p_destProcessType == P_TYPE.PSC) { p_docInfo.strDocFile = string.Format("{0}_{1}", p_faxId, p_tmkDtlInfo.faxDtlId); } else { p_docInfo.strDocFile = string.Format("{0}_{1}_tifmake", p_faxId, p_tmkDtlInfo.faxDtlId); } string strFileName = string.Format("{0}.{1}", p_docInfo.strDocFile, p_docInfo.strDocExt); //// 파일경로이름 SET //// string strFinishFile = ""; string strMakingFile = string.Format(@"{0}\{1}", Config.TIFF_MAKING_PATH, strFileName); if (p_destProcessType == P_TYPE.PSC) { strFinishFile = string.Format(@"{0}\{1}", Config.FINISHED_TIF_PATH, p_tmkDtlInfo.strTiffPath); } else { strFinishFile = string.Format(@"{0}\{1}", Config.MADE_TIF_PATH, strFileName); } string strPacketXmlFile = string.Format(@"{0}\{1}_{2}.xml", Config.TIFF_MAKING_PATH, p_faxId, p_tmkDtlInfo.faxDtlId); //// TIFF 생성 //// try { //// 팩스폼 로딩 //// if (!File.Exists(p_strFaxFormLocal)) { LogError(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] 팩스폼파일을 찾을수 없습니다.(파일:{2})", p_faxId, p_tmkDtlInfo.faxDtlId, p_strFaxFormLocal), RESULT.F_MAKE_NOT_EXIST_FAXFORMFILE); return(RESULT.F_MAKE_NOT_EXIST_FAXFORMFILE); } //// Page fault 처리 - 스트림 생성 //// using (MemoryStream faxFormStream = new MemoryStream()) { using (Stream localFaxFormStream = File.OpenRead(p_strFaxFormLocal)) { localFaxFormStream.CopyTo(faxFormStream); localFaxFormStream.Close(); } using (XtraReport_Btfax report = new XtraReport_Btfax()) { report.LoadLayout(p_strFaxFormLocal); LogMessage(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] 팩스폼파일 로딩성공 (파일:{2})", p_faxId, p_tmkDtlInfo.faxDtlId, p_strFaxFormLocal), RESULT.SUCCESS); //// 전문 XML 로딩 //// report.LoadPacketXml(p_strPacket, p_strTrNo, false, true); //// 레포트 데이터셋에 팩스번호, 수신인명 바인딩 처리 //// DataSet reportDs = report.DataSource as DataSet; if (reportDs == null) { LogError(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] 팩스폼에 데이터셋이 존재하지 않습니다 (파일:{2})", p_faxId, p_tmkDtlInfo.faxDtlId, p_strFaxFormLocal), RESULT.F_MAKE); return(RESULT.F_MAKE); } DataTable reportDt = reportDs.Tables["헤더___HEADER_O_COMMON"]; if (reportDt == null) { LogError(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] 팩스폼에 데이터셋이 존재하지 않습니다 (파일:{2})", p_faxId, p_tmkDtlInfo.faxDtlId, p_strFaxFormLocal), RESULT.F_MAKE); return(RESULT.F_MAKE); } bool bFaxNumBinded = false; bool bFaxRecipientNameBinded = false; foreach (DataColumn col in reportDt.Columns) { foreach (DataRow row in reportDt.Rows) { if (bFaxNumBinded && bFaxRecipientNameBinded) { break; } if (col.ColumnName == "수신자팩스번호") { row[col.ColumnName] = p_tmkDtlInfo.strFaxNo; bFaxNumBinded = true; } if (col.ColumnName == "수신자이름") { row[col.ColumnName] = p_tmkDtlInfo.strRecipientName; bFaxRecipientNameBinded = true; } } } //// 컨트롤 바인딩 처리 //// foreach (Band band in report.Bands) { foreach (XRControl control in band.Controls) { //// 이미지 외, 컨트롤 바인딩 유효성 체크 //// if (control is XRLabel || control is XRCheckBox || control is XRTableCell) { result = ValidateBinding(report, control); if (result != RESULT.SUCCESS) { return(result); } } //// 이미지 바인딩 유효성 체크 및 동적 바인딩 //// else if (control is XRPictureBox) { XRPictureBox xrPictureBox = control as XRPictureBox; result = BindImageBox(report, xrPictureBox); if (result != RESULT.SUCCESS) { throw new Exception(); } } } } //// Export /// //report.ExportToImage(strMakingFile, this.exportOption); if (!report.ExportImageForFax(Config.TIFF_MAKING_PATH, strFileName)) { LogError(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] TIF파일 생성실패 (파일:{2})", p_faxId, p_tmkDtlInfo.faxDtlId, strMakingFile), RESULT.F_MAKE); return(RESULT.F_MAKE); } LogMessage(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] TIF파일 생성성공 (파일:{2})", p_faxId, p_tmkDtlInfo.faxDtlId, strMakingFile), RESULT.SUCCESS); //// 파일 업로드 //// if (!UploadFinishedTif(strMakingFile, strFinishFile)) { LogError(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] TIF파일 업로드실패 (파일:{2}->{3})", p_faxId, p_tmkDtlInfo.faxDtlId, strMakingFile, strFinishFile), RESULT.F_FILE_FAIL_TO_UPLOAD); return(RESULT.F_FILE_FAIL_TO_UPLOAD); } LogMessage(string.Format("[FAX_ID:{0}][FAX_DTL_ID:{1}] TIF파일 업로드성공 (파일:{2}->{3})", p_faxId, p_tmkDtlInfo.faxDtlId, strMakingFile, strFinishFile), RESULT.SUCCESS); if (reportDt != null) { reportDt.Dispose(); } if (reportDs != null) { reportDs.Dispose(); } // LHOPE File.Delete(strMakingFile); } faxFormStream.Close(); return(RESULT.SUCCESS); } } catch (Exception ex) { LogError(string.Format("팩스 발송 요청에 대하여 팩스폼[{0}]으로 TIFF 파일[{1}]을 생성하는 도중., 다음과 같은 오류가 발생하였습니다. {2}", p_strFaxFormFullPath, strMakingFile, ex.Message), RESULT.F_MAKE); return(RESULT.F_MAKE); } }
static void Main(string[] strArgs) { // 프로세스 아규먼트 처리 if (strArgs.Length <= 0) { MessageBox.Show("프로세스 아이디가 입력되지 않았습니다", "실행 오류", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!long.TryParse(strArgs[0], out Config.PROCESS_NO)) { MessageBox.Show("프로세스 아이디가 잘못되었습니다.", "실행 오류", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //// 환경 파일 로딩 //// string iniFile = string.Format("{0}\\..\\Btfax.ini", Application.StartupPath); if (!Config.LoadIni(iniFile)) { MessageBox.Show(string.Format("환경파일({0}) 읽기 실패.", iniFile), "실행 오류", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CommonMsgBox.IsMsgPopup = false; //// 윈폼 생성 //// Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Program.s_frmMain = new FrmMain(); //// 초기화 //// AppLog.LogDefaultPath = Application.StartupPath + "\\log"; AppLog.LogPrefix = string.Format("FAX_{0}_TMK_{1}", Config.SYSTEM_NO, Config.PROCESS_NO); //AppLog.IsDisplay = false; //AppLog.DisplayDelegate = Program.s_frmMain.Display_AddLog; //Config.DisplayDelegate = Program.s_frmMain.Display_Config; //// 프로세스 시작 //// Config.APP_VER = string.Format("v{0}", Assembly.GetExecutingAssembly().GetName().Version); AppLog.Write(LOG_LEVEL.MSG, string.Format("### TMK {0} 프로세스 시작 ###", Config.APP_VER)); #if DEBUG AppLog.Write(LOG_LEVEL.MSG, "### This is DEBUG mode. ###"); #endif //// DB 접속 //// if (!DbModule.Instance.Open(Config.DB_CONNECTION_STRING)) { AppLog.Write(LOG_LEVEL.ERR, "DB 접속에 실패하였습니다"); return; } AppLog.Write(LOG_LEVEL.MSG, "DB : 접속 완료"); //// 환경 DB 로딩 //// if (!Config.LoadDb()) { AppLog.Write(LOG_LEVEL.ERR, "DB환경설정 읽기를 실패하였습니다"); return; } AppLog.LogLevel = Config.LOG_LEVEL; AppLog.Write(LOG_LEVEL.MSG, "실행환경 적용 완료"); //// 암호화 모듈 초기화 //// if (Config.ENCRYPT_FIELD_YN == "Y") { if (File.Exists(Config.ENCRYPT_DLL_FILE)) { if (!EncryptApi.InitApi(Config.ENCRYPT_DLL_FILE)) { AppLog.Write(LOG_LEVEL.WRN, string.Format("암호화 모듈({0})로드 실패", Config.ENCRYPT_DLL_FILE)); } else { AppLog.Write(LOG_LEVEL.MSG, string.Format("암호화 모듈({0})로드 성공", Config.ENCRYPT_DLL_FILE)); } } else { AppLog.Write(LOG_LEVEL.WRN, string.Format("암호화 모듈({0}) 이 존재하지 않습니다.", Config.ENCRYPT_DLL_FILE)); } } //// 쓰레드 객체 생성 //// s_DbPollingThread = DbPollingThread.Instance; //// 윈폼 실행 //// try { //// 쓰레드 시작 //// Program.Thread_Start(); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(ApplicationThreadException); Application.Run(Program.s_frmMain); //// 쓰레드 종료 //// Program.Thread_Stop(); } catch (Exception ex) { //// 쓰레드 종료 //// Program.Thread_Stop(); AppLog.ExceptionLog(ex, "어플리케이션 예외가 발생하였습니다."); } //// 프로세스 종료 로그 기록 //// AppLog.Write(LOG_LEVEL.MSG, "### TMK 프로세스 종료 ###"); }