public override string OnApproveWaitInitial(long workFlowID, object eventData) { WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.GetSCGDocumentByDocumentID(workFlow.Document.DocumentID); Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); MPADocument mpaDocument = ScgeAccountingQueryProvider.MPADocumentQuery.GetMPADocumentByDocumentID(workFlow.Document.DocumentID); IList <long> advanceWorkflowIDs = new List <long>(); if (!errors.IsEmpty) { throw new SS.Standard.Utilities.ServiceValidationException(errors); } string signal = base.OnApproveWaitInitial(workFlowID, eventData); // ====================== For Approve all advance that link to TA ====================== // Use state WaitInitial to add into table WorkflowResponse string eventName = "Approve"; WorkFlowStateEvent stateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetByWorkFlowStateID_EventName(AdvanceStateID.WaitInitial, eventName); //SubmitResponse submitResponse = eventData as SubmitResponse; return(signal); }
protected void ctlConfirmPopup_OnNotifyPopup(object sender, PopUpReturnArgs args) { int intWorkFlowStateEventID = 0; try { if (args.Type == PopUpReturnType.OK) { WorkFlowStateEvent workFlowStateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetSendDraftStateEvent(WorkFlowTypeID.FixedAdvanceWorkFlow); intWorkFlowStateEventID = workFlowStateEvent.WorkFlowStateEventID; object eventData = new SubmitResponse(intWorkFlowStateEventID); WorkFlowService.NotifyEvent(this.WorkflowID, workFlowStateEvent.Name, eventData); Response.Redirect("SubmitResult.aspx?wfid=" + this.WorkflowID); } } catch (ServiceValidationException ex) { this.ValidationErrors.MergeErrors(ex.ValidationErrors); ctlUpdatePanelValidation.Update(); } if (this.ValidationErrors.IsEmpty) { Response.Redirect("DocumentView.aspx?wfid=" + this.WorkflowID.ToString()); } }
public void NotifyImageFile(long documentID) { //FnAutoPayment p = SCG.eAccounting.Query.ScgeAccountingQueryProvider.FnAutoPaymentQuery.GetFnAutoPaymentByDocumentID(documentID); //if (p.Status != 2) return; bool b = ScgeAccountingDaoProvider.FnAutoPaymentTempDao.IsSuccess(documentID); if (b) { return; } bool commitSuccess = ScgeAccountingDaoProvider.FnAutoPaymentTempDao.CommitToAutoPayment(documentID); if (!commitSuccess) { return; } WorkFlow wf = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(documentID); WorkFlowStateEvent wfse = WorkFlowQueryProvider .WorkFlowStateEventQuery .GetByWorkFlowStateID_EventName(wf.CurrentState.WorkFlowStateID, "Pay"); SubmitResponse sr = new SubmitResponse(wfse.WorkFlowStateEventID); sr.ResponseMethod = ResponseMethod.SAP; //WorkFlowService.NotifyEventFromExternal(wf.WorkFlowID, 1, 1, "Pay", sr); //WorkFlowService.NotifyEvent(wf.WorkFlowID, "Pay", sr); //Using new method on 30/04/2009 WorkFlowService.NotifyEventFromInternal(wf.WorkFlowID, "Pay", sr); }
protected void ctlConfirmPopup_OnNotifyPopup(object sender, PopUpReturnArgs args) { try { if (args.Type == PopUpReturnType.OK) { WorkFlowStateEvent workFlowStateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetSendDraftStateEvent(WorkFlowTypeID.RemittanceWorkFlow); int intWorkFlowStateEventID = workFlowStateEvent.WorkFlowStateEventID; object eventData = new SubmitResponse(intWorkFlowStateEventID); WorkFlowService.NotifyEvent(this.WorkFlowID, workFlowStateEvent.Name, eventData); Response.Redirect("SubmitResult.aspx?wfid=" + this.WorkFlowID); } } catch (ServiceValidationException ex) { this.ValidationErrors.MergeErrors(ex.ValidationErrors); ctlUpdatePanelValidation.Update(); } // if No error then redirect to SubmitResult.aspx if (this.ValidationErrors.IsEmpty) { //Page.RegisterStartupScript("comfirm", "<script>return confirm('Do you want to send your document to WorkFlow')</script>"); Response.Redirect("DocumentView.aspx?wfid=" + this.WorkFlowID.ToString()); } }
public void LoadEvent(string eventName, string stateName) { Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); try { IList <SearchResultData> resultList = new List <SearchResultData>(); long workFlowID; int workFlowStateEventID; if (stateName.Equals(WorkFlowStateFlag.Draft)) { resultList = ctlInboxEmployeeSearchResultDraft.GetGridViewDataList(); } if (stateName.Equals(WorkFlowStateFlag.WaitInitial)) { resultList = ctlInboxEmployeeSearchResultWaitInitial.GetGridViewDataList(); } if (stateName.Equals(WorkFlowStateFlag.WaitApprove)) { resultList = ctlInboxEmployeeSearchResultWaitApprove.GetGridViewDataList(); } if (stateName.Equals(WorkFlowStateFlag.WaitAgree)) { resultList = ctlInboxEmployeeSearchResultWaitAgree.GetGridViewDataList(); } foreach (SearchResultData result in resultList) { workFlowID = 0; workFlowStateEventID = 0; WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(result.DocumentID); if (workFlow != null) { workFlowID = workFlow.WorkFlowID; workFlowStateEventID = ScgeAccountingQueryProvider.SCGDocumentQuery.GetWorkStateEvent(workFlow.CurrentState.WorkFlowStateID, eventName); object eventData = new SubmitResponse(workFlowStateEventID); WorkFlowStateEvent workFlowStateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.FindByIdentity(workFlowStateEventID); if (workFlowStateEvent != null) { WorkFlowService.NotifyEvent(workFlowID, workFlowStateEvent.Name, eventData); } } } } catch (ServiceValidationException ex) { errors.MergeErrors(ex.ValidationErrors); } ctlUpdatePanelValidation.Update(); }
public override string OnWithdrawWaitInitial(long workFlowID, object eventData) { string signal = base.OnWithdrawWaitInitial(workFlowID, eventData); // Withdraw all advance that link to TA WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); MPADocument mpaDocument = ScgeAccountingQueryProvider.MPADocumentQuery.GetMPADocumentByDocumentID(workFlow.Document.DocumentID); string eventName = "Withdraw"; WorkFlowStateEvent stateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetByWorkFlowStateID_EventName(AdvanceStateID.WaitInitial, eventName); return(signal); }
public override string OnOverRoleWaitInitial(long workFlowID, object eventData) { /*TODO validate , save event data to workflow*/ /* TODO generate signal string * Case 1 : OverRoleWaitInitialToWaitInitial * Case 2 : OverRoleWaitInitialToWaitApprove */ string signal = base.OnOverRoleWaitInitial(workFlowID, eventData); // ====================== For Overrole all advance that link to TA ====================== WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); MPADocument mpaDocument = ScgeAccountingQueryProvider.MPADocumentQuery.GetMPADocumentByDocumentID(workFlow.Document.DocumentID); string eventName = "OverRole"; // Use state WaitInitial to add into table WorkflowResponse WorkFlowStateEvent stateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetByWorkFlowStateID_EventName(AdvanceStateID.WaitInitial, eventName); return(signal); }
public override string OnRejectWaitApprove(long workFlowID, object eventData) { /*TODO validate , save event data to workflow*/ WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.GetSCGDocumentByDocumentID(workFlow.Document.DocumentID); MPADocument mpaDocument = ScgeAccountingQueryProvider.MPADocumentQuery.GetMPADocumentByDocumentID(scgDocument.DocumentID); RejectDetailResponse rejectDetailResponse; try { if (eventData is SubmitResponse) { rejectDetailResponse = DefaultRejectDetailResponse((eventData as SubmitResponse).WorkFlowStateEventID, (eventData as SubmitResponse).ResponseMethod); } else { rejectDetailResponse = eventData as RejectDetailResponse; } WorkFlowResponse response = new WorkFlowResponse(); response.WorkFlow = workFlow; response.WorkFlowStateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.FindByIdentity(rejectDetailResponse.WorkFlowStateEventID); response.ResponseBy = UserAccount.UserID; response.ResponseDate = DateTime.Now; if (rejectDetailResponse.ResponseMethod != null) { response.ResponseMethod = rejectDetailResponse.ResponseMethod.GetHashCode().ToString(); } response.Active = true; response.CreBy = UserAccount.UserID; response.CreDate = DateTime.Now; response.UpdBy = UserAccount.UserID; response.UpdDate = DateTime.Now; response.UpdPgm = "WorkFlow"; WorkFlowDaoProvider.WorkFlowResponseDao.Save(response); WorkFlowRejectResponse rejectResponse = new WorkFlowRejectResponse(); rejectResponse.WorkFlowResponse = response; rejectResponse.Reason = ScgDbQueryProvider.DbRejectReasonQuery.FindProxyByIdentity(rejectDetailResponse.ReasonID); rejectResponse.Remark = rejectDetailResponse.Remark; rejectResponse.Active = true; rejectResponse.CreBy = UserAccount.UserID; rejectResponse.CreDate = DateTime.Now; rejectResponse.UpdBy = UserAccount.UserID; rejectResponse.UpdDate = DateTime.Now; rejectResponse.UpdPgm = "WorkFlow"; WorkFlowDaoProvider.WorkFlowRejectResponseDao.Save(rejectResponse); SCGEmailService.SendEmailEM04(response.WorkFlowResponseID, scgDocument.CreatorID.Userid); if (ParameterServices.EnableEmail02Requester || ParameterServices.EnableEmail02Initiator) { long sendToUserID = 0; IList <long> ccList = new List <long>(); if (ParameterServices.EnableEmail02Requester) { if (scgDocument.CreatorID.Userid != scgDocument.RequesterID.Userid) { sendToUserID = scgDocument.RequesterID.Userid; } IList <MPAItem> items = ScgeAccountingQueryProvider.MPAItemQuery.FindMPAItemByMPADocumentID(mpaDocument.MPADocumentID); foreach (MPAItem item in items) { if (sendToUserID == 0) { sendToUserID = item.UserID.Userid; } else if (item.UserID.Userid != sendToUserID && !ccList.Contains(item.UserID.Userid)) { ccList.Add(item.UserID.Userid); } } } if (ParameterServices.EnableEmail02Initiator) { IList <DocumentInitiator> initiators = ScgeAccountingQueryProvider.DocumentInitiatorQuery.GetDocumentInitiatorByDocumentID(scgDocument.DocumentID); foreach (DocumentInitiator initiator in initiators) { if (sendToUserID == 0) { sendToUserID = initiator.UserID.Userid; } else if (initiator.UserID.Userid != sendToUserID && !ccList.Contains(initiator.UserID.Userid)) { ccList.Add(initiator.UserID.Userid); } } } SCGEmailService.SendEmailEM02(response.WorkFlowResponseID, sendToUserID, ccList); } } catch (Exception) { throw; } // Use state WaitInitial to add into table WorkflowResponse string eventName = "Reject"; WorkFlowStateEvent stateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetByWorkFlowStateID_EventName(AdvanceStateID.WaitApprove, eventName); rejectDetailResponse.WorkFlowStateEventID = stateEvent.WorkFlowStateEventID; /*TODO generate signal string*/ return("RejectWaitApproveToDraft"); }
public override string OnApproveWaitApprove(long workFlowID, object eventData) { /*TODO validate , save event data to workflow*/ WorkFlow workFlow = WorkFlowQueryProvider.WorkFlowQuery.FindByIdentity(workFlowID); SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.GetSCGDocumentByDocumentID(workFlow.Document.DocumentID); Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); MPADocument mpaDocument = ScgeAccountingQueryProvider.MPADocumentQuery.GetMPADocumentByDocumentID(workFlow.Document.DocumentID); if (!errors.IsEmpty) { throw new SS.Standard.Utilities.ServiceValidationException(errors); } try { ////SubmitResponse submitResponse = eventData as SubmitResponse; WorkFlowResponse response = new WorkFlowResponse(); int workFlowStateEventId; response.WorkFlow = workFlow; response.ResponseBy = UserAccount.UserID; response.ResponseDate = DateTime.Now; response.Active = true; response.CreBy = UserAccount.UserID; response.CreDate = DateTime.Now; response.UpdBy = UserAccount.UserID; response.UpdDate = DateTime.Now; response.UpdPgm = UserAccount.CurrentProgramCode; if (eventData is RejectDetailResponse) { RejectDetailResponse rejectDetailResponse = eventData as RejectDetailResponse; workFlowStateEventId = rejectDetailResponse.WorkFlowStateEventID; WorkFlowRejectResponse rejectResponse = new WorkFlowRejectResponse(); rejectResponse.WorkFlowResponse = response; if (rejectDetailResponse.ReasonID != 0) { rejectResponse.Reason = ScgDbQueryProvider.DbRejectReasonQuery.FindProxyByIdentity(rejectDetailResponse.ReasonID); } rejectResponse.Remark = rejectDetailResponse.Remark; rejectResponse.Active = true; rejectResponse.CreBy = UserAccount.UserID; rejectResponse.CreDate = DateTime.Now; rejectResponse.UpdBy = UserAccount.UserID; rejectResponse.UpdDate = DateTime.Now; rejectResponse.UpdPgm = UserAccount.CurrentProgramCode; if (rejectDetailResponse.ResponseMethod != null) { response.ResponseMethod = rejectDetailResponse.ResponseMethod.GetHashCode().ToString(); } response.WorkFlowStateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.FindByIdentity(workFlowStateEventId); WorkFlowDaoProvider.WorkFlowResponseDao.Save(response); if (rejectDetailResponse.ReasonID != 0 || !string.IsNullOrEmpty(rejectDetailResponse.Remark)) { WorkFlowDaoProvider.WorkFlowRejectResponseDao.Save(rejectResponse); } } else { SubmitResponse submitResponse = eventData as SubmitResponse; workFlowStateEventId = submitResponse.WorkFlowStateEventID; if (submitResponse.ResponseMethod != null) { response.ResponseMethod = submitResponse.ResponseMethod.GetHashCode().ToString(); } response.WorkFlowStateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.FindByIdentity(workFlowStateEventId); WorkFlowDaoProvider.WorkFlowResponseDao.Save(response); } scgDocument.ApproveDate = DateTime.Now; scgDocument.UpdBy = UserAccount.UserID; scgDocument.UpdDate = DateTime.Now; scgDocument.UpdPgm = UserAccount.CurrentProgramCode; SCGDocumentService.SaveOrUpdate(scgDocument); if (ParameterServices.EnableEmail02Creator || ParameterServices.EnableEmail02Requester || ParameterServices.EnableEmail02Initiator) { long sendToUserID = 0; IList <long> ccList = new List <long>(); if (ParameterServices.EnableEmail02Creator) { sendToUserID = scgDocument.CreatorID.Userid; } if (ParameterServices.EnableEmail02Requester) { if (sendToUserID == 0) { sendToUserID = scgDocument.RequesterID.Userid; } else if (scgDocument.CreatorID.Userid != scgDocument.RequesterID.Userid) { ccList.Add(scgDocument.RequesterID.Userid); } //Send mail02 to all travellers that doesnot requester IList <MPAItem> items = ScgeAccountingQueryProvider.MPAItemQuery.FindMPAItemByMPADocumentID(mpaDocument.MPADocumentID); foreach (MPAItem item in items) { if (sendToUserID == 0) { sendToUserID = item.UserID.Userid; } else if (item.UserID.Userid != sendToUserID && !ccList.Contains(item.UserID.Userid)) { ccList.Add(item.UserID.Userid); } } } if (ParameterServices.EnableEmail02Initiator) { IList <DocumentInitiator> initiators = ScgeAccountingQueryProvider.DocumentInitiatorQuery.GetDocumentInitiatorByDocumentID(workFlow.Document.DocumentID); foreach (DocumentInitiator initiator in initiators) { if (sendToUserID == 0) { sendToUserID = initiator.UserID.Userid; } else if (initiator.UserID.Userid != sendToUserID && !ccList.Contains(initiator.UserID.Userid)) { ccList.Add(initiator.UserID.Userid); } } } SCGEmailService.SendEmailEM02(response.WorkFlowResponseID, sendToUserID, ccList); } } catch (Exception) { throw; } // ====================== For Approve all advance that link to TA ====================== // Use state WaitApprove to add into table WorkflowResponse string eventName = "Approve"; WorkFlowStateEvent stateEvent = WorkFlowQueryProvider.WorkFlowStateEventQuery.GetByWorkFlowStateID_EventName(AdvanceStateID.WaitApprove, eventName); return("ApproveWaitApproveToComplete"); }