private void SPMAfterSend_DBIO(SPMTaskVariables SPMTaskVars, EFFormFields FormFields, ref IInterfaceHandleResult HandleResult, SPMRoutingVariable RoutingVariable)
    {
        try
        {
            string       stepName              = (string)SPMTaskVars.ReadDatum("STEPNAME");
            int          caseID                = int.Parse((string)(SPMTaskVars.ReadDatum("CASEID")));
            NPIMgmt      oMgmt                 = new NPIMgmt(oUIControls.lblSite.Text, oUIControls.lblBu.Text);
            NPI_Standard oStandard             = oMgmt.InitialLeaveMgmt();
            Dictionary <string, object> result = new Dictionary <string, object>();
            Model_PRELAUNCH_MAIN        oModel = new Model_PRELAUNCH_MAIN();
            string Handler = oPara.LoginId;
            switch (RoutingVariable.Key)
            {
            case SPMRoutingVariableKey.spm_Recall:
                //修改本单据数据状态为Abort

                oModel._CaseId = caseID;
                oModel._Status = "Abort";

                result = oStandard.RecordOperation_PrelaunchMain(oModel, Status_Operation.UPDATE);
                if (!(bool)result["Result"])
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = (string)result["ErrMsg"];
                }

                break;

            case SPMRoutingVariableKey.spm_Jump:
                //1.标示当前关卡已核准(如为最后一关,则变更状态为Finished)
                string ApproverRemark = string.Empty;
                string ApproverResult = string.Empty;
                for (int i = 0; i < oUIControls.rgResult.Items.Count; i++)
                {
                    if (oUIControls.rgResult.Items[i].Checked == true)
                    {
                        ApproverResult = oUIControls.rgResult.Items[i].BoxLabel.Trim();
                    }
                }
                result = oStandard.UpdateDOAHandlerStatus(caseID, stepName, Handler, ApproverResult, oUIControls.txtReslutOpinion.Text.Trim());

                if (!(bool)result["Result"])
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = (string)result["ErrMsg"];
                }
                break;
            }
        }
        catch (Exception e)
        {
            HandleResult.IsSuccess     = false;
            HandleResult.CustomMessage = e.Message;
        }
    }
    public override void SPM_SendError(SPMSubmitMethod SubmitMethod, SPMTaskVariables SPMTaskVars, SPMVariables Variables, SPMRoutingVariable RoutingVariable, EFFormFields FormFields, IInterfaceHandleResult HandleResult)
    {
        string strExceptionFrom = HandleResult.ExceptionFrom;
        string strErrorMessage  = HandleResult.CustomMessage;

        base.SPM_SendError(SubmitMethod, SPMTaskVars, Variables, RoutingVariable, FormFields, HandleResult);
    }
    // Code for 'before send'
    public override void SPMBeforeSend(SPMSubmitMethod SubmitMethod, SPMTaskVariables SPMTaskVars, SPMVariables Variables, SPMRoutingVariable RoutingVariable, ref EFFormFields FormFields, ref IInterfaceHandleResult HandleResult)
    {
        if (RoutingVariable != null)
        {
            switch (RoutingVariable.Key)
            {
            case SPMRoutingVariableKey.spm_Return:

                string value = RoutingVariable.Data;

                break;
            }
        }

        base.SPMBeforeSend(SubmitMethod, SPMTaskVars, Variables, RoutingVariable, ref FormFields, ref HandleResult);
    }
    // Code for 'after send'
    public override void SPMAfterSend(SPMSubmitMethod SubmitMethod, SPMTaskVariables SPMTaskVars, SPMVariables Variables, SPMRoutingVariable RoutingVariable, EFFormFields FormFields, ref IInterfaceHandleResult HandleResult)
    {
        string caseid = System.Web.HttpUtility.UrlDecode(Variables[SPMVariableKey.CaseId]);

        if (RoutingVariable != null)
        {
            string sRoutingData = string.Empty;
            switch (RoutingVariable.Key)
            {
            case SPMRoutingVariableKey.spm_Return:

                sRoutingData = RoutingVariable.Data;

                break;

            case SPMRoutingVariableKey.spm_Jump:

                sRoutingData = RoutingVariable.Data;
                break;
            }
        }


        //// Business logic
        if (SubmitMethod != SPMSubmitMethod.CreateNewCase)
        {
            SPMAfterSend_DBIO(SPMTaskVars, FormFields, ref HandleResult, RoutingVariable);
        }
        else
        {
            ////////1.待签核关卡及签核人写DB

            NPIMgmt      oNPIMgmt  = new NPIMgmt(oUIControls.lblSite.Text, oUIControls.lblBu.Text);
            NPI_Standard oStandard = oNPIMgmt.InitialLeaveMgmt();

            Dictionary <string, object> result = oStandard.RecordDOAHandler(caseid, oUIControls.txtFormNo.Text, oUIControls.lblBu.Text, oUIControls.cmbPlant.SelectedItem.Text, oUIControls.cmbPhase.SelectedItem.Text);
            if (!(bool)result["Result"])
            {
                HandleResult.IsSuccess     = false;
                HandleResult.CustomMessage = (string)result["ErrMsg"];
            }

            else
            {
                StringBuilder sbLayout = new StringBuilder();
                if (oUIControls.cmbLayout.SelectedItems.Count > 0)
                {
                    foreach (SelectedListItem li in oUIControls.cmbLayout.SelectedItems)
                    {
                        sbLayout.AppendFormat("{0},", li.Text);
                    }
                }

                Model_NPI_APP_MAIN_HIS oModel_Main = new Model_NPI_APP_MAIN_HIS();
                oModel_Main._DOC_NO         = oUIControls.txtFormNo.Text.Trim();
                oModel_Main._BU             = oUIControls.lblBu.Text;
                oModel_Main._BUILDING       = oUIControls.cmbPlant.SelectedItem.Text;
                oModel_Main._APPLY_DATE     = oUIControls.txtDate.Text;
                oModel_Main._APPLY_USERID   = oPara.LoginId.Trim();
                oModel_Main._MODEL_NAME     = oUIControls.txtModel.Text;
                oModel_Main._CUSTOMER       = oUIControls.txtCustomer.Text;
                oModel_Main._PRODUCT_TYPE   = oUIControls.cbProductType.SelectedItem.Text;
                oModel_Main._LAYOUT         = sbLayout.ToString().TrimEnd(',');
                oModel_Main._PHASE          = oUIControls.cmbPhase.SelectedItem.Text;
                oModel_Main._NEXTSTAGE_DATE = oUIControls.txtNextStage_BeginDate.SelectedDate.ToString("yyyy/MM/dd");
                oModel_Main._NPI_PM         = oUIControls.txtPM.Text;
                oModel_Main._SALES_OWNER    = oUIControls.txtSales.Text;
                oModel_Main._RD_ENGINEER    = oUIControls.txtRD.Text;
                oModel_Main._REMARK         = oUIControls.txtNotes.Text;
                oModel_Main._CASEID         = oPara.CaseId.ToString();
                oModel_Main._UPDATE_USERID  = oPara.LoginId;
                oModel_Main._STATUS         = "Pending";

                oModel_Main._PMLOC    = oUIControls.cmbPM.SelectedItem.Text.Trim();
                oModel_Main._PMEXT    = oUIControls.txtPMExt.Text.Trim();
                oModel_Main._RDLOC    = oUIControls.cmbRD.SelectedItem.Text.Trim();
                oModel_Main._RDEXT    = oUIControls.txtRDExt.Text.Trim();
                oModel_Main._SALESLOC = oUIControls.cmbSales.SelectedItem.Text.Trim();
                oModel_Main._SALESEXT = oUIControls.txtSalesExt.Text.Trim();

                result = oStandard.RecordOperation_NPIMain(oModel_Main, Status_Operation.ADD);

                //result = "true";

                if (!(bool)result["Result"])
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = (string)result["ErrMsg"];
                }
            }
        }
        base.SPMAfterSend(SubmitMethod, SPMTaskVars, Variables, RoutingVariable, FormFields, ref HandleResult);
    }
    // Fill SPM Variable
    public override void PrepareSPMVariables(SPMSubmitMethod SubmitMethod, SPMProcessMethod ProcessMethod, SPMTaskVariables SPMTaskVars, ref SPMVariables Variables, ref SPMRoutingVariable RoutingVariable, ref string strSPMUid, string strMemo, string strNotesForNextApprover, EFFormFields FormFields, ref IInterfaceHandleResult HandleResult, ref string SuccessMessage)
    {
        bool   isError   = false;
        string stepName  = string.Empty;
        string errorMsg  = string.Empty;
        string FormNo    = FormFields["txtFormNo".ToUpper()];
        string Applicant = oPara.LoginId;

        Variables.Add(SPMVariableKey.Subject, "[NPIReport_Application] [" + FormNo + "] By [" + Applicant + "]");
        string  Approver = string.Empty;
        NPIMgmt oMgmt    = new NPIMgmt(oUIControls.lblSite.Text, oUIControls.lblBu.Text);
        //NPIMgmt oMgmt = new NPIMgmt("CZ1","HIS");
        NPI_Standard oStandard = oMgmt.InitialLeaveMgmt();

        if (SubmitMethod == SPMSubmitMethod.CreateNewCase)
        {
            DataTable dtDOAHandler = oModel_NPI_DOA_HandlerInfo._HANDLER;
            if (dtDOAHandler.Rows.Count > 0)
            {
                DataRow dr        = dtDOAHandler.Rows[0];
                string  step_name = dr["STEP_NAME"].ToString();
                string  handler   = dr["HANDLER"].ToString();
                RoutingVariable = new SPMRoutingVariable(SPMRoutingVariableKey.spm_NextHandler, step_name + "(" + handler + ")");
            }
            else
            {
                HandleResult.IsSuccess     = false;
                HandleResult.CustomMessage = "無法獲取下一關簽核人信息,請聯絡系統管理員!";
            }
        }
        if (SubmitMethod == SPMSubmitMethod.HandleCase_Approve)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();
            stepName = (string)SPMTaskVars.ReadDatum("STEPNAME");
            int caseID = int.Parse((string)(SPMTaskVars.ReadDatum("CASEID")));
            ////获取待签核关卡及签核人资讯
            result = oStandard.GetNextStepAndHandler_NPI(caseID, FormNo, stepName, oUIControls.cmbPlant.SelectedItem.Text, oUIControls.cmbPhase.SelectedItem.Text);
            if (!(bool)result["Result"])//无法找到签核关卡资讯,显示ERROR
            {
                HandleResult.IsSuccess     = false;
                HandleResult.CustomMessage = (string)result["ErrMsg"];
            }
            else
            {
                try
                {
                    RoutingVariable = new SPMRoutingVariable(SPMRoutingVariableKey.spm_Jump, (string)result["SPMRoutingVariable"]);
                }
                catch (Exception ex)
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = "DOA Error:" + ex.Message;
                }
                if (RoutingVariable == null)
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = "Error: get RoutingVariable fail";
                }
            }
        }
        base.PrepareSPMVariables(SubmitMethod, ProcessMethod, SPMTaskVars, ref Variables, ref RoutingVariable, ref strSPMUid, strMemo, strNotesForNextApprover, FormFields, ref HandleResult, ref SuccessMessage);
    }
Example #6
0
    private void SPMAfterSend_DBIO(SPMTaskVariables SPMTaskVars, EFFormFields FormFields, ref IInterfaceHandleResult HandleResult, SPMRoutingVariable RoutingVariable, SPMVariables Variables)
    {
        try
        {
            string stepName = (string)SPMTaskVars.ReadDatum("STEPNAME");
            int    caseID   = int.Parse((string)(SPMTaskVars.ReadDatum("CASEID")));


            switch (RoutingVariable.Key)
            {
            //if Reject,Post Back To SAP
            case SPMRoutingVariableKey.spm_Return:
                try
                {
                    PostBackToSAP(SPMTaskVars, FormFields, Variables, "R");
                    oStandard.UpdateFormStatus(caseID, "Reject");
                }
                catch (Exception ex)
                {
                    HandleResult.IsSuccess     = false;
                    HandleResult.CustomMessage = ex.Message;
                }
                break;

            case SPMRoutingVariableKey.spm_Jump:
                string curDOA  = FormFields["txtDOA".ToUpper()].Replace("&lt1;", "<").Replace("&gt1;", ">");
                string curStep = SPMAppLine.GetCurrentStep(curDOA);
                //最後一關結束 將結果拋到DB中 並更新STATUS欄位為 Approve
                if (curStep == "*")
                {
                    try
                    {
                        //  IF APPROVE ,POST BACK TO SAP and Update Form Status Approve
                        PostBackToSAP(SPMTaskVars, FormFields, Variables, "A");
                        oStandard.UpdateFormStatus(caseID, "Approve");
                    }
                    catch (Exception ex)
                    {
                        HandleResult.IsSuccess     = false;
                        HandleResult.CustomMessage = ex.Message;
                    }
                }
                break;
            }
        }
        catch (Exception e)
        {
            HandleResult.IsSuccess     = false;
            HandleResult.CustomMessage = e.Message;
        }
    }
Example #7
0
    // Code for 'after send'
    public override void SPMAfterSend(SPMSubmitMethod SubmitMethod, SPMTaskVariables SPMTaskVars, SPMVariables Variables, SPMRoutingVariable RoutingVariable, EFFormFields FormFields, ref IInterfaceHandleResult HandleResult)
    {
        if (SubmitMethod != SPMSubmitMethod.CreateNewCase)
        {
            SPMAfterSend_DBIO(SPMTaskVars, FormFields, ref HandleResult, RoutingVariable, Variables);
        }
        else
        {
            GDS_Helper oStandard      = new GDS_Helper();
            string     CASEID         = System.Web.HttpUtility.UrlDecode(Variables[SPMVariableKey.CaseId]); //CASEID
            string     Werks          = oUIControls.txtWERKS.Text;
            string     DocNo          = oUIControls.txtDocNo.Text;                                          //主單號
            string     RDocNo         = oUIControls.txtRDocNo.Text;                                         //Link 單號
            string     CostCenter     = oUIControls.txtCostCenter.Text;                                     //成本中心
            string     Department     = oUIControls.txtDepartment.Text;                                     //部門
            string     Application    = oUIControls.txtApplication.Text;                                    //申請人
            string     ZEILE          = oUIControls.txtZEILE.Text;                                          //ITEM
            string     Material       = oUIControls.txtMaterial.Text;                                       //料號
            string     ReturnQuantity = oUIControls.txtReturnQuantity.Text;                                 //退料數量
            string     Reason         = oUIControls.txtReason.Text;                                         //退料原因
            string     Remark         = oUIControls.txtRemark.Text;                                         //備註
            string     Return         = oUIControls.txtReturn.Text;                                         //條件FLAG Flag為Y才符合條件
            string     IADocNo        = oUIControls.txtIADocNo.Text;                                        //關聯IA單
            string     I6DocNo        = oUIControls.txtI6DocNo.Text;                                        //關聯I6單
            string     Amount         = oUIControls.txtAmount.Text;                                         //金額
            string     Settingxml     = oUIControls.txtDOA.Text;                                            //Setting
            try
            {
                //Insert Submit之後數據到DB中
                oStandard.Insert_Begin(Werks, DocNo, RDocNo, CostCenter, Department, Application, ZEILE, Material, ReturnQuantity, Return, Reason, Remark, IADocNo, I6DocNo, "In Process", double.Parse(Amount), Settingxml, int.Parse(CASEID));

                //將Submit後的狀態 W(In Process)回傳給SAP Begin關卡直接回傳
                oStandard.PostBackToSAP(int.Parse(CASEID));
            }
            catch (Exception ex)
            {
                //有異常 刪除已經Insert的資料
                oStandard.DeleteFormNo(int.Parse(CASEID));
                HandleResult.IsSuccess     = false;
                HandleResult.CustomMessage = ex.Message;
            }
        }
        base.SPMAfterSend(SubmitMethod, SPMTaskVars, Variables, RoutingVariable, FormFields, ref HandleResult);
    }
Example #8
0
 // Code for 'before send'
 public override void SPMBeforeSend(SPMSubmitMethod SubmitMethod, SPMTaskVariables SPMTaskVars, SPMVariables Variables, SPMRoutingVariable RoutingVariable, ref EFFormFields FormFields, ref IInterfaceHandleResult HandleResult)
 {
     base.SPMBeforeSend(SubmitMethod, SPMTaskVars, Variables, RoutingVariable, ref FormFields, ref HandleResult);
 }
Example #9
0
    // Fill SPM Variable
    public override void PrepareSPMVariables(SPMSubmitMethod SubmitMethod, SPMProcessMethod ProcessMethod, SPMTaskVariables SPMTaskVars, ref SPMVariables Variables, ref SPMRoutingVariable RoutingVariable, ref string strSPMUid, string strMemo, string strNotesForNextApprover, EFFormFields FormFields, ref IInterfaceHandleResult HandleResult, ref string SuccessMessage)
    {
        if (SubmitMethod == SPMSubmitMethod.CreateNewCase)
        {
            GDS_Helper    oStandard = new GDS_Helper();
            StringBuilder ErrMsg    = new StringBuilder();


            //string stepName = (string)(SPMTaskVars.ReadDatum("STEPNAME"));
            string curDOA = oUIControls.txtDOA.Text;
            string plant  = oUIControls.txtWERKS.Text;
            string apType = oUIControls.txtAPTYP.Text;


            DOA    spmDOA     = new DOA();
            string sApplicant = oUIControls.txtApplication.Text.Trim();
            //獲取 表頭及表身DATA
            string    formDetail          = oUIControls.txtDetail.Text.Trim().Replace("&lt1;", "<").Replace("&gt1;", ">");
            string    formHead            = oUIControls.txtHead.Text.Trim().Replace("&lt1;", "<").Replace("&gt1;", ">");
            DataTable dtHead              = LiteOn.GDS.Utility.Tools.BuildHeadTable();
            System.IO.StringReader reader = new System.IO.StringReader(formHead);
            dtHead.ReadXml(reader);
            System.IO.StringReader reader2 = new System.IO.StringReader(formDetail);
            DataTable dtDetail             = LiteOn.GDS.Utility.Tools.BuildDetailTable();
            dtDetail.ReadXml(reader2);
            try
            {
                //抓取第一關簽核人
                DOAHandler = spmDOA.GetStepHandler(sApplicant, curDOA, dtHead, dtDetail, true);
                Variables.Add(SPMVariableKey.Subject, "[部門領料_應退未退---測試] [" + FormFields["txtDocNo".ToUpper()] + "]");
                RoutingVariable = new SPMRoutingVariable(SPMRoutingVariableKey.spm_Jump, "DOA(" + DOAHandler._sHandler + ")");
            }
            catch (Exception ex)
            {
                HandleResult.IsSuccess     = false;
                HandleResult.CustomMessage = ex.Message;
            }
        }
        else
        {
            try
            {
                if (DOAHandler._sEndFlag == "N")
                {
                    //簽核人防呆檢查
                    if (DOAHandler._sHandler.Length == 0)
                    {
                        HandleResult.IsSuccess     = false;
                        HandleResult.CustomMessage = "Operation fail(server or network is busy now), pls refresh this page and try again";
                    }
                    else
                    {
                        RoutingVariable = new SPMRoutingVariable(SPMRoutingVariableKey.spm_Jump, "DOA(" + DOAHandler._sHandler + ")");
                        // 20121105 Add QX NA
                        if (DOAHandler._cc.Length > 0)
                        {
                            Variables.Add(SPMVariableKey.NextCC, DOAHandler._cc);
                        }
                        // 20121105 End QX NA
                    }
                }
                else
                {
                    RoutingVariable = new SPMRoutingVariable(SPMRoutingVariableKey.spm_Jump, "End");
                }

                // DBIO.RecordTraceLog("D", "OK", DOAHandler);
            }
            catch (Exception)
            {
                DBIO.RecordTraceLog("D", "NG", DOAHandler);
                throw;
            }
        }

        base.PrepareSPMVariables(SubmitMethod, ProcessMethod, SPMTaskVars, ref Variables, ref RoutingVariable, ref strSPMUid, strMemo, strNotesForNextApprover, FormFields, ref HandleResult, ref SuccessMessage);
    }