private static void ValidateWorkflow(ServiceWorkflowOutstandingTransaction wat, string lange, ref int warningCount, ref string message) { if (wat.Workflow.MemberFunction == null) { warningCount++; message = Messages.Genaral.IsNotMemberFunction.Format(lange); } }
public static TransitionEvent GetTransitionEventOf(ServiceWorkflowOutstandingTransaction transaction, params TransitionEventCode[] transitionEventCodes) { foreach (var c in transitionEventCodes) { foreach (var e in transaction.PermissibleEvents) { if (e.TransitionEvent.Code == c) { return(e.TransitionEvent); } } } return(null); }
public static void ApproveFinanceTransaction(BizPortalSessionContext context, string[] eventNameAndId, string remark, ref string message, ref int warningCount, DateTime newValueDate = default(DateTime)) { string lange = context.CurrentLanguage.Code; string mark = ""; ServiceWorkflowOutstandingTransaction wat = null; using (ITransaction tx = context.PersistenceSession.BeginTransaction()) { var eventNameEng = TransitionEventCode.CreateEvent; try { int eventID = int.Parse(eventNameAndId[2]); //Find event var t = TransitionEventCode.CreateEvent; switch (int.Parse(eventNameAndId[2])) { case (int)TransitionEventCode.StopEvent: t = TransitionEventCode.StopEvent; eventNameEng = TransitionEventCode.StopEvent; break; case (int)TransitionEventCode.ApproveFinalEvent: t = TransitionEventCode.ApproveFinalEvent; eventNameEng = TransitionEventCode.ApproveFinalEvent; break; case (int)TransitionEventCode.ApproveFirstEvent: t = TransitionEventCode.ApproveFirstEvent; eventNameEng = TransitionEventCode.ApproveFirstEvent; break; case (int)TransitionEventCode.ApproveIntermediateEvent: t = TransitionEventCode.ApproveIntermediateEvent; eventNameEng = TransitionEventCode.ApproveIntermediateEvent; break; case (int)TransitionEventCode.RejectEvent: t = TransitionEventCode.RejectEvent; eventNameEng = TransitionEventCode.RejectEvent; break; case (int)TransitionEventCode.ReturnEvent: t = TransitionEventCode.ReturnEvent; eventNameEng = TransitionEventCode.ReturnEvent; break; } wat = new ServiceWorkflowOutstandingTransaction(context, eventNameAndId[1]); if (newValueDate != default(DateTime)) { wat.Transaction.EffectiveDate = newValueDate; } mark = wat.CurrentStateRemark; // is not use wat.CurrentStateRemark case if (warningCount == 0) { ValidateWorkflow(wat, lange, ref warningCount, ref message); } else { return; } //Validate are Approve Event only if (eventID == (int)TransitionEventCode.ApproveFirstEvent || eventID == (int)TransitionEventCode.ApproveFinalEvent || eventID == (int)TransitionEventCode.ApproveIntermediateEvent) { if (warningCount == 0) { ValidateValueDate(context, wat.Transaction, ref warningCount, ref message); } else { return; } if (warningCount == 0) { ValidateAmountLimit(context, wat.Transaction, ref warningCount, ref message); } else { return; } if (warningCount == 0) { ValidateDataEntry(context, wat.Transaction, ref warningCount, ref message); } else { return; } } if (warningCount == 0) { wat.Transaction.Transit(context, wat.Workflow, mark, t); wat.Transaction.Remark = remark; wat.Transaction.Persist(context); //Hard if (wat.Transaction.DebitWindow.From <= DateTime.Now && DateTime.Now <= wat.Transaction.DebitWindow.To && wat.Transaction.CurrentStateCode == StateCode.Approved) { ((FundsTransferTransactionOneToMany)wat.Transaction).Transit(context, wat.Workflow, "Timeout debit transaction [" + wat.TransactionNo + "]", TransitionEventCode.DebitTimeoutEvent); context.Persist(wat.Transaction.CurrentState); } tx.Commit(); message = string.Format("{0} {1}", eventNameAndId[0], Messages.Genaral.ApprovalSuccess.Format(context.CurrentLanguage.Code)); context.Log(wat.Transaction.FunctionID, 0, 0, GetFunctionName(lange, eventNameEng), mark); } } catch (Exception exception) { warningCount++; tx.Rollback(); context.PersistenceSession.Clear(); message = string.Empty; message += ExceptionMessages.ApproveFinanceException; if (wat != null) { context.Log(wat.Transaction.FunctionID, ClientWebPageID.ApproveView, 0, ActionLog.Exception, IBankException.LogMessageProgramError(exception, ExceptionMessages.ApproveFinanceException.Code + "-" + string.Format("ฟังก์ชัน : {0} : {1}", GetFunctionName(lange, eventNameEng), mark))); } } } }
public static void ApproveFinanceOverValueDateTransaction(BizPortalSessionContext context, string[] eventNameAndId, string remark, ref string message, ref int warningCount) { ServiceWorkflowOutstandingTransaction wat = null; try { wat = new ServiceWorkflowOutstandingTransaction(context, eventNameAndId[1]); DateTime originalValueDate = wat.Transaction.EffectiveDate; string originalTransferFee = wat.Transaction.TotalFee(); //Find new EffectiveDate DateTime effective; TimeInterval debitWindow; TimeInterval exportWindow; var standard = wat.Transaction.Member. GetEffectiveMemberOrStandardFundsTransferServiceProfile(context, wat.Transaction.Service.ServiceCode, wat.Transaction.PostedTS); standard.FindNearestPossibleTransactionDates(context, out effective, out debitWindow, out exportWindow); wat.Transaction.EffectiveDate = effective; wat.Transaction.DebitWindow = debitWindow; wat.Transaction.ExportWindow = exportWindow; string logMessage = string.Format( "วันที่รายการมีผลเดิม {0} เปลี่ยนเป็น วันที่ {1} ค่าธรรมเนียม {2}", originalValueDate.DateFormat(), effective.DateFormat(), originalTransferFee); if (warningCount == 0) { ValidateValueDate(context, wat.Transaction, ref warningCount, ref message); } else { return; } if (warningCount == 0) { ValidateAmountLimit(context, wat.Transaction, ref warningCount, ref message); } else { return; } if (warningCount == 0) { ValidateDataEntry(context, wat.Transaction, ref warningCount, ref message); } else { return; } context.Log(wat.Transaction.FunctionID, 0, 0, "Change Value date of transaction", logMessage); //Call Method Approv finance ApproveFinanceTransaction(context, eventNameAndId, remark, ref message, ref warningCount); } catch (Exception exception) { warningCount++; context.PersistenceSession.Clear(); message = string.Empty; message += ExceptionMessages.ApproveFinanceException; if (wat != null) { context.Log(wat.Transaction.FunctionID, ClientWebPageID.ApproveView, 0, ActionLog.Exception, IBankException.LogMessageProgramError(exception, ExceptionMessages.ChangeValueDateException.Code + "-" + string.Format("ฟังก์ชัน : {0} : {1}", "Change Value date of transaction", wat.CurrentStateRemark))); } } }