/// <summary> /// 기안, 재기안, 수정기안 /// </summary> public void SetDraft() { string KPI_REF_ID = Request["KPI_REF_ID"].ToString(); string ymd = GetRequest("YMD", ""); Biz_Com_Approval_Info objApp = new Biz_Com_Approval_Info(); bool blnRtn = false; //결재완결처리 결재선이 하나인경우 완결처리 string sAppStatus = (ugrdAppLine.Rows.Count == 1) ? Biz_Type.app_status_complete : Biz_Type.app_status_draft; //기안 if (this.IDraft_Status == Biz_Type.app_draft_first) //최초기안 { if (GetRequest("KPI_REF_ID", "").Split(',').Length < 1) { ltrScript.Text = JSHelper.GetAlertScript("결재처리할 KPI코드를 확인하세요!"); return; } IDbConnection conn = MicroBSC.Data.DbAgentHelper.CreateDbConnection(); conn.Open(); IDbTransaction trx = conn.BeginTransaction(); string strTermid = GetRequest("ESTTERM_REF_ID"); //현재 시점에 결재여부 재확인 MicroBSC.BSC.Biz.Biz_Bsc_Kpi_Info objkpi = new MicroBSC.BSC.Biz.Biz_Bsc_Kpi_Info(); DataSet dsKPI = new DataSet(); if (this.IBiz_Type == Biz_Type.biz_type_kpi_docbatch) { dsKPI = objkpi.GetKpiListForBatchDraft(DataTypeUtility.GetToInt32(strTermid) , "", "", "Y", gUserInfo.Emp_Ref_ID, GetRequest("KPI_REF_ID")); } else if (this.IBiz_Type == Biz_Type.biz_type_kpi_rstbatch) { dsKPI = objkpi.GetKpiResultListForBatchDraft(DataTypeUtility.GetToInt32(strTermid) , ymd, "", "", "Y", gUserInfo.Emp_Ref_ID, GetRequest("KPI_REF_ID")); } else if (this.IBiz_Type == Biz_Type.biz_type_target_resultbatch) { dsKPI = objkpi.GetKpiResultListForBatchDraft(DataTypeUtility.GetToInt32(strTermid) , ymd, "", "", "N", gUserInfo.Emp_Ref_ID, GetRequest("KPI_REF_ID")); } if (dsKPI.Tables[0].Rows.Count > 0) { if (dsKPI.Tables[0].Rows.Count != KPI_REF_ID.Split(',').Length) { trx.Rollback(); conn.Close(); conn.Dispose(); this.IApp_Ref_Id = 0; this.IVersion_No = 0; ltrScript.Text = JSHelper.GetAlertScript("결재대상 KPI상태를 확인하세요!", true); return; } if (dsKPI.Tables[0].Select("APP_STATUS NOT IN('NFT', 'MFT', 'AFT', 'RFT')").Length > 0) { trx.Rollback(); conn.Close(); conn.Dispose(); this.IApp_Ref_Id = 0; this.IVersion_No = 0; ltrScript.Text = JSHelper.GetAlertScript("결재대상 KPI상태를 확인하세요!", true); return; } } else { trx.Rollback(); conn.Close(); conn.Dispose(); this.IApp_Ref_Id = 0; this.IVersion_No = 0; ltrScript.Text = JSHelper.GetAlertScript("결재대상 KPI상태를 확인하세요!", true); return; } foreach (string strKpiRefId in KPI_REF_ID.Split(',')) { blnRtn = false; try { NameValueCollection nvc = new NameValueCollection(); nvc.Add("ESTTERM_REF_ID", strTermid); nvc.Add("KPI_REF_ID", strKpiRefId); nvc.Add("YMD", ymd); string strTitle = ""; if (this.IBiz_Type == Biz_Type.biz_type_kpi_docbatch) { blnRtn = objApp.GetOriDocTitle(Biz_Type.biz_type_kpi_doc, nvc, out strTitle); } else if (this.IBiz_Type == Biz_Type.biz_type_kpi_rstbatch) { blnRtn = objApp.GetOriDocTitle(Biz_Type.biz_type_kpi_rst, nvc, out strTitle); } else if (this.IBiz_Type == Biz_Type.biz_type_target_resultbatch) { blnRtn = objApp.GetOriDocTitle(Biz_Type.biz_type_target_result, nvc, out strTitle); } if (blnRtn) { txtTitle.Text = strTitle; } else { trx.Rollback(); conn.Close(); conn.Dispose(); this.IApp_Ref_Id = 0; this.IVersion_No = 0; ltrScript.Text = JSHelper.GetAlertScript("결재처리 중 결재원문을 알수 없습니다.", true); return; } string queryURL = string.Empty; string strFullPath = ""; string strPath = ""; string strParam = string.Empty; if (this.IBiz_Type == Biz_Type.biz_type_kpi_docbatch) { strParam = "ESTTERM_REF_ID=" + strTermid + "&KPI_REF_ID=" + strKpiRefId + "&BIZ_TYPE=" + Biz_Type.biz_type_kpi_doc + "&APP_REF_ID=0&DRAFT_EMP_ID=" + gUserInfo.Emp_Ref_ID.ToString(); strPath = Biz_Com_Approval_Info.GetDraftPagePath(Biz_Type.biz_type_kpi_doc); } else if (this.IBiz_Type == Biz_Type.biz_type_kpi_rstbatch) { strParam = "ESTTERM_REF_ID=" + strTermid + "&KPI_REF_ID=" + strKpiRefId + "&YMD=" + ymd + "&BIZ_TYPE=" + Biz_Type.biz_type_kpi_rst + "&APP_REF_ID=0&DRAFT_EMP_ID=" + gUserInfo.Emp_Ref_ID.ToString(); strPath = Biz_Com_Approval_Info.GetDraftPagePath(Biz_Type.biz_type_kpi_rst); } else if (this.IBiz_Type == Biz_Type.biz_type_target_resultbatch) { strParam = "ESTTERM_REF_ID=" + strTermid + "&KPI_REF_ID=" + strKpiRefId + "&YMD=" + ymd + "&BIZ_TYPE=" + Biz_Type.biz_type_target_result + "&APP_REF_ID=0&DRAFT_EMP_ID=" + gUserInfo.Emp_Ref_ID.ToString(); strPath = Biz_Com_Approval_Info.GetDraftPagePath(Biz_Type.biz_type_kpi_rst); } string strVPath = Request.ApplicationPath; string strSHost = Request.Url.Host; string strSPort = Request.Url.Port.ToString(); string strProto = Request.Url.Scheme; strVPath = (strVPath == "/") ? "" : strVPath; strFullPath = strProto + "://" + strSHost + ":" + strSPort + strVPath + strPath + "?" + strParam; string strHtml = Server.HtmlDecode(Biz_Com_Approval_Info.GetHtmlSource(strFullPath)); string strPos = "{^0^}"; int iSPos = strHtml.IndexOf(strPos) + strPos.Length; int iEPos = strHtml.LastIndexOf(strPos); divArea_M.InnerHtml = strHtml.Substring(iSPos, iEPos - iSPos); NameValueCollection nvc2 = new NameValueCollection(); nvc2.Add("ESTTERM_REF_ID", strTermid); nvc2.Add("KPI_REF_ID", strKpiRefId); if (this.IBiz_Type == Biz_Type.biz_type_kpi_docbatch) { nvc2.Add("BIZ_TYPE", Biz_Type.biz_type_kpi_doc); } else if (this.IBiz_Type == Biz_Type.biz_type_kpi_rstbatch) { nvc2.Add("BIZ_TYPE", Biz_Type.biz_type_kpi_rst); nvc2.Add("YMD", ymd); } else if (this.IBiz_Type == Biz_Type.biz_type_target_resultbatch) { nvc2.Add("BIZ_TYPE", Biz_Type.biz_type_target_result); nvc2.Add("YMD", ymd); } nvc2.Add("APP_REF_ID", "0"); nvc2.Add("DRAFT_EMP_ID", gUserInfo.Emp_Ref_ID.ToString()); if (this.IBiz_Type == Biz_Type.biz_type_kpi_docbatch) { blnRtn = objApp.TxrDraftBatch(conn, trx, Server.HtmlEncode(divArea_M.InnerHtml) , txtTitle.Text , Biz_Type.biz_type_kpi_doc , sAppStatus , Biz_Type.app_draft_first , "" , gUserInfo.Emp_Ref_ID , this.GetAPPLine(), nvc2); } else if (this.IBiz_Type == Biz_Type.biz_type_kpi_rstbatch) { blnRtn = objApp.TxrDraftBatch(conn, trx, Server.HtmlEncode(divArea_M.InnerHtml) , txtTitle.Text , Biz_Type.biz_type_kpi_rst , sAppStatus , Biz_Type.app_draft_first , "" , gUserInfo.Emp_Ref_ID , this.GetAPPLine(), nvc2); } else if (this.IBiz_Type == Biz_Type.biz_type_target_resultbatch) { blnRtn = objApp.TxrDraftBatch(conn, trx, Server.HtmlEncode(divArea_M.InnerHtml) , txtTitle.Text , Biz_Type.biz_type_target_result , sAppStatus , Biz_Type.app_draft_first , "" , gUserInfo.Emp_Ref_ID , this.GetAPPLine(), nvc2); } if (!blnRtn) { trx.Rollback(); conn.Close(); conn.Dispose(); this.IApp_Ref_Id = 0; this.IVersion_No = 0; ltrScript.Text = JSHelper.GetAlertScript("결재 일괄처리 중 오류가 발생하였습니다."); ltrScript.Text = JSHelper.GetAlertOpenerControlCallBackScript(objApp.Transaction_Message, this.IAPP_CCB, true); return; } this.IApp_Ref_Id = objApp.IApp_Ref_Id; this.IVersion_No = objApp.IVersion_No; if (this.IHISTORY_YN == "Y") { DoInsertUpdateReason(); } } catch { trx.Rollback(); conn.Close(); conn.Dispose(); this.IApp_Ref_Id = 0; this.IVersion_No = 0; ltrScript.Text = JSHelper.GetAlertScript("결재 일괄처리 중 오류가 발생하였습니다."); ltrScript.Text = JSHelper.GetAlertOpenerControlCallBackScript(objApp.Transaction_Message, this.IAPP_CCB, true); return; } } trx.Commit(); conn.Close(); conn.Dispose(); try { bool bRtn = this.SendMailBatch(false); } catch { } ltrScript.Text = JSHelper.GetAlertOpenerControlCallBackScript(objApp.Transaction_Message, this.IAPP_CCB, true); } else { ltrScript.Text = JSHelper.GetAlertScript("결재형식이 올바르지 않습니다!"); return; } }