/// <summary> /// Main execution function for NewPawnLoanFlowExecutor /// </summary> /// <param name="inputData"></param> /// <returns></returns> private object executorFxn(object inputData) { var inputState = NewPawnLoanFlowState.LookupCustomer; if (inputData == null && !GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.DESCRIBEMERCHANDISE)) { if (GlobalDataAccessor.Instance.DesktopSession.TabStateClicked != FlowTabController.State.None) { inputState = NewPawnLoanFlowState.InvokePawnCustInformationFlow; } else if (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer != null && !string.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber) && GlobalDataAccessor.Instance.DesktopSession.TabStateClicked == FlowTabController.State.None) { IsGunMerchandiseLookedUp lookupGunMdseFxn = CommonAppBlocks.Instance.IsGunMerchandiseLookedUpBlock; lookupGunMdseFxn.execute(); inputState = lookupGunMdseFxn.Value ? NewPawnLoanFlowState.ManagePawnApplication : NewPawnLoanFlowState.InvokeMMPIChildFlow; } } else if (inputData != null) { inputState = (NewPawnLoanFlowState)inputData; if (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer != null && !string.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber) && GlobalDataAccessor.Instance.DesktopSession.TabStateClicked == FlowTabController.State.None && GlobalDataAccessor.Instance.DesktopSession.StartNewPawnLoan) { inputState = NewPawnLoanFlowState.InvokeMMPIChildFlow; } } //If the trigger is describe merchandise for a new pawn loan invoke mmpi flow if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.DESCRIBEMERCHANDISE)) { if (inputState == NewPawnLoanFlowState.LookupCustomer) { //If merchandise is already looked up then we are looking to lookup customer IsLoanMerchandiseLookedUp lookupMdseFxn = CommonAppBlocks.Instance.IsLoanMerchandiseLookedUpBlock; lookupMdseFxn.execute(); //Check if tab state is null..if it is not null then pawncustinfo flow should be invoked if (GlobalDataAccessor.Instance.DesktopSession.TabStateClicked != FlowTabController.State.None) { inputState = NewPawnLoanFlowState.InvokePawnCustInformationFlow; } else if (lookupMdseFxn.Value && (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer == null || string.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber))) { inputState = NewPawnLoanFlowState.LookupCustomer; } else { IsGunMerchandiseLookedUp lookupGunMdseFxn = CommonAppBlocks.Instance.IsGunMerchandiseLookedUpBlock; lookupGunMdseFxn.execute(); if (lookupGunMdseFxn.Value) { inputState = NewPawnLoanFlowState.ManagePawnApplication; } else { inputState = NewPawnLoanFlowState.InvokeMMPIChildFlow; } } } } else { //If the customer is already looked up go straight to manage pawn application IsCustomerLookedUp lookupFxn = CommonAppBlocks.Instance.IsCustomerLookedUpBlock; lookupFxn.execute(); if (lookupFxn.Value == true && inputState == NewPawnLoanFlowState.LookupCustomer) { inputState = NewPawnLoanFlowState.ManagePawnApplication; } } switch (inputState) { case NewPawnLoanFlowState.LookupCustomer: ShowForm lookupCustBlk = CommonAppBlocks.Instance.CreateLookupCustomerShowBlock(this.parentForm, this.lookupCustFormNavAction); if (!lookupCustBlk.execute()) { throw new ApplicationException("Cannot execute LookupCustomer block"); } break; case NewPawnLoanFlowState.LookupCustomerResults: ShowForm lookupCustResBlk = CommonAppBlocks.Instance.CreateLookupCustomerResultsBlock(this.parentForm, this.lookupCustResultsFormNavAction); if (!lookupCustResBlk.execute()) { throw new ApplicationException("Cannot execute LookupCustomerResults block"); } break; case NewPawnLoanFlowState.AddCustomer: if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.NEWPAWNLOAN, StringComparison.OrdinalIgnoreCase)) { ShowForm manageCustBlk = CommonAppBlocks.Instance.CreateManagePawnApplicationBlock(this.parentForm, this.managePawnAppFormNavAction); if (!manageCustBlk.execute()) { throw new ApplicationException("Cannot execute Manage Pawn Application block"); } } else { ShowForm createCustBlk = CommonAppBlocks.Instance.CreateCreateCustomerBlock(this.parentForm, this.createCustomerFormNavAction); if (!createCustBlk.execute()) { throw new ApplicationException("Cannot execute CreateCustomer block"); } } break; case NewPawnLoanFlowState.ExistingCustomer: ShowForm existCustBlk = CommonAppBlocks.Instance.CreateExistingCustomerBlock(this.parentForm, this.existCustomerFormNavAction); if (!existCustBlk.execute()) { throw new ApplicationException("Cannot execute ExistingCustomer block"); } break; case NewPawnLoanFlowState.ManagePawnApplication: ShowForm managePawnAppBlk = CommonAppBlocks.Instance.CreateManagePawnApplicationBlock(this.parentForm, this.managePawnAppFormNavAction); if (!managePawnAppBlk.execute()) { throw new ApplicationException("Cannot execute ManagePawnApplication block"); } break; case NewPawnLoanFlowState.ViewCustomerInformation: ShowForm viewCustInfoBlk = CommonAppBlocks.Instance.ViewCustomerInfoShowBlock(this.parentForm, this.viewCustInfoFormNavAction); if (!viewCustInfoBlk.execute()) { throw new ApplicationException("Cannot execute View Customer Information block"); } break; case NewPawnLoanFlowState.ViewReadOnlyCustomerInformation: ShowForm viewCustInfoReadOnlyBlk = CommonAppBlocks.Instance.ViewCustomerInfoShowBlock(this.parentForm, this.viewCustInfoFormNavAction); if (!viewCustInfoReadOnlyBlk.execute()) { throw new ApplicationException("Cannot execute View customer information Read Only block"); } ((ViewCustomerInformation)viewCustInfoReadOnlyBlk.ClassForm).ShowReadOnly = true; break; case NewPawnLoanFlowState.InvokeMMPIChildFlow: //Initiate the child workflow if (GlobalDataAccessor.Instance.DesktopSession.PawnLoans.Count == 0) { GlobalDataAccessor.Instance.DesktopSession.PawnLoans.Add(new PawnLoan()); } GlobalDataAccessor.Instance.DesktopSession.AppController.invokeWorkflow(MMPIFUNCTIONALITYNAME, this.parentForm, this.endStateNotifier, this); break; case NewPawnLoanFlowState.InvokePawnCustInformationFlow: GlobalDataAccessor.Instance.DesktopSession.AppController.invokeWorkflow(PAWNCUSTINFOFLOW, this.parentForm, this.endStateNotifier, this); break; case NewPawnLoanFlowState.CancelFlow: CommonAppBlocks.Instance.HideFlowTabController(); if (this.endStateNotifier != null) { this.endStateNotifier.execute(); } break; case NewPawnLoanFlowState.ExitFlow: break; default: throw new ApplicationException("Invalid new pawn loan flow state"); } return(true); }
/// <summary> /// Main execution function for NewPawnLoanFlowExecutor /// </summary> /// <param name="inputData"></param> /// <returns></returns> private object executorFxn(object inputData) { if (inputData == null) { return(false); } MMPIFlowState inputState = (MMPIFlowState)inputData; if (parentFlow != null) { parentFlowName = parentFlow.Name; } if (inputState == MMPIFlowState.DescribeItem) { //check if activepawnloan is null or activepurchase is null if (parentFlowName.Equals("CustomerPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) { IsBuyMerchandiseLookedUp lookupFxn = CommonAppBlocks.Instance.IsBuyMerchandiseLookedUpBlock; lookupFxn.execute(); //check if customer is looked up IsCustomerLookedUp lookupCustFxn = CommonAppBlocks.Instance.IsCustomerLookedUpBlock; lookupCustFxn.execute(); if (lookupFxn.Value == false) { inputState = MMPIFlowState.DescribeMerchandise; } //both merchandise and customer looked up and its describe item flow in customer purchase else if (lookupFxn.Value && lookupCustFxn.Value && GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.DESCRIBEITEMCUSTOMERPURCHASE, StringComparison.OrdinalIgnoreCase) && GlobalDataAccessor.Instance.DesktopSession.DescribeItemContext != CurrentContext.EDIT_MMP) { if (GlobalDataAccessor.Instance.DesktopSession.DescribeItemContext == CurrentContext.NEW && (GlobalDataAccessor.Instance.DesktopSession.DescribeItemPawnItemIndex >= 0 || GlobalDataAccessor.Instance.DesktopSession.ActivePurchase.ProductDataComplete)) { List <Item> items = GlobalDataAccessor.Instance.DesktopSession.ActivePurchase.Items; if (!(string.IsNullOrEmpty(items[items.Count - 1].TicketDescription))) { inputState = MMPIFlowState.ManageMultiplePawnItems; } } } } else if (parentFlowName.Equals("VendorPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) { IsBuyMerchandiseLookedUp lookupFxn = CommonAppBlocks.Instance.IsBuyMerchandiseLookedUpBlock; lookupFxn.execute(); if (lookupFxn.Value == false) { inputState = MMPIFlowState.DescribeMerchandise; } else if (!string.IsNullOrEmpty(CashlinxDesktopSession.Instance.ActivePurchase.PurchaseOrderNumber)) { inputState = MMPIFlowState.ManageMultiplePawnItems; } } else if (parentFlowName.Equals("NewPawnLoanFlowExecutor", StringComparison.OrdinalIgnoreCase) || GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.DESCRIBEMERCHANDISE, StringComparison.OrdinalIgnoreCase)) { IsLoanMerchandiseLookedUp lookupFxn = CommonAppBlocks.Instance.IsLoanMerchandiseLookedUpBlock; lookupFxn.execute(); if (lookupFxn.Value == false) { inputState = MMPIFlowState.DescribeMerchandise; } else if (GlobalDataAccessor.Instance.DesktopSession.ActivePawnLoan.Items[0].mStore == 0) { GlobalDataAccessor.Instance.DesktopSession.DescribeItemPawnItemIndex = 0; inputState = MMPIFlowState.DescribeItem; } else { //check if customer is looked up IsCustomerLookedUp lookupCustFxn = CommonAppBlocks.Instance.IsCustomerLookedUpBlock; lookupCustFxn.execute(); if (lookupFxn.Value && lookupCustFxn.Value && GlobalDataAccessor.Instance.DesktopSession.DescribeItemContext != CurrentContext.EDIT_MMP) { if (GlobalDataAccessor.Instance.DesktopSession.DescribeItemContext == CurrentContext.NEW && GlobalDataAccessor.Instance.DesktopSession.DescribeItemPawnItemIndex == -1 || GlobalDataAccessor.Instance.DesktopSession.ActivePawnLoan.ProductDataComplete) { List <Item> items = GlobalDataAccessor.Instance.DesktopSession.ActivePawnLoan.Items; if (!(string.IsNullOrEmpty(items[items.Count - 1].TicketDescription))) { inputState = MMPIFlowState.ManageMultiplePawnItems; } } else if (GlobalDataAccessor.Instance.DesktopSession.DescribeItemContext == CurrentContext.NEW && (GlobalDataAccessor.Instance.DesktopSession.DescribeItemPawnItemIndex >= 0)) { inputState = MMPIFlowState.DescribeItem; } } } } else { if (GlobalDataAccessor.Instance.DesktopSession.ActivePawnLoan == null || GlobalDataAccessor.Instance.DesktopSession.ActivePawnLoan.Items == null || GlobalDataAccessor.Instance.DesktopSession.ActivePawnLoan.Items.Count == 0) { inputState = MMPIFlowState.DescribeMerchandise; } } } switch (inputState) { case MMPIFlowState.DescribeMerchandise: ShowForm describeMerchBlk = CommonAppBlocks.Instance.DescribeMerchandiseBlock(this.parentForm, this.describeMerchFormAction); if (!describeMerchBlk.execute()) { throw new ApplicationException("Cannot execute Describe Merchandise block"); } if (!(parentFlowName.Equals("CustomerPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) && !(parentFlowName.Equals("VendorPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) && (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer != null && !String.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber))) { SetTabsInForm(describeMerchBlk); } break; case MMPIFlowState.DescribeItem: ShowForm describeItemBlk = CommonAppBlocks.Instance.DescribeItemBlock(this.parentForm, this.describeItemFormAction); if (!describeItemBlk.execute()) { throw new ApplicationException("Cannot execute Describe Item Block"); } //show tabs only if its not new pawn loan flow that called this child flow if (!(parentFlowName.Equals("CustomerPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) && !(parentFlowName.Equals("VendorPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) && (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer != null && !String.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber))) { //Check if Manage multiple pawn items form is still there //If it is, no need to show the tabs if (!(GlobalDataAccessor.Instance.DesktopSession.HistorySession.Lookup("ManageMultiplePawnItems"))) { SetTabsInForm(describeItemBlk); } } break; case MMPIFlowState.ManageMultiplePawnItems: if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Lookup("ManageMultiplePawnItems")) { //Remove the MMPI form and reload GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back(); } ShowForm mmpiBlk = CommonAppBlocks.Instance.ManageMultiplePawnItemsBlock(this.parentForm, this.multiplePawnItemsFormAction); if (!mmpiBlk.execute()) { throw new ApplicationException("Cannot execute Manage Multiple Pawn Items Block"); } if (!(parentFlowName.Equals("CustomerPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) && !(parentFlowName.Equals("VendorPurchaseFlowExecutor", StringComparison.OrdinalIgnoreCase)) && (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer != null && !String.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber))) { SetTabsInForm(mmpiBlk); } break; case MMPIFlowState.CancelFlow: CommonAppBlocks.Instance.HideFlowTabController(); if (this.endStateNotifier != null) { this.endStateNotifier.execute(); } break; case MMPIFlowState.ExitFlowToItemHistory: if (parentFlow != null) { GlobalDataAccessor.Instance.DesktopSession.TabStateClicked = FlowTabController.State.ItemHistory; this.parentFlow.execute(); } break; case MMPIFlowState.ExitFlowToProductHistory: if (parentFlow != null) { GlobalDataAccessor.Instance.DesktopSession.TabStateClicked = FlowTabController.State.ProductHistory; this.parentFlow.execute(); } break; case MMPIFlowState.ExitFlowToViewCustomer: if (parentFlow != null) { GlobalDataAccessor.Instance.DesktopSession.TabStateClicked = FlowTabController.State.Customer; this.parentFlow.execute(); } break; case MMPIFlowState.ExitFlowToLookupCustomer: GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back(); if (parentFlow != null) { this.parentFlow.execute(); } break; case MMPIFlowState.ExitFlowToVendor: CashlinxDesktopSession.Instance.HistorySession.Back(); if (parentFlow != null) { this.parentFlow.execute(); } break; case MMPIFlowState.ExitFlowToStats: if (parentFlow != null) { GlobalDataAccessor.Instance.DesktopSession.TabStateClicked = FlowTabController.State.Stats; this.parentFlow.execute(); } break; default: throw new ApplicationException("Invalid MMPI flow state"); } return(true); }
/// <summary> /// Main execution function for CustomerPurchaseFlowExecutor /// </summary> /// <param name="inputData"></param> /// <returns></returns> private object executorFxn(object inputData) { if (inputData == null) { inputData = suspendedState; } PurchaseFlowState inputState = (PurchaseFlowState)inputData; //If the customer is already looked up go straight to manage pawn application IsCustomerLookedUp lookupFxn = CommonAppBlocks.Instance.IsCustomerLookedUpBlock; lookupFxn.execute(); if (inputState == PurchaseFlowState.LookupCustomer && GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(DESCRIBEITEMTRIGGER, StringComparison.OrdinalIgnoreCase)) { //If merchandise is already looked up then we are looking to lookup customer IsBuyMerchandiseLookedUp lookupMdseFxn = CommonAppBlocks.Instance.IsBuyMerchandiseLookedUpBlock; lookupMdseFxn.execute(); inputState = lookupMdseFxn.Value ? PurchaseFlowState.LookupCustomer : PurchaseFlowState.InvokeMMPIChildFlow; } switch (inputState) { case PurchaseFlowState.LookupCustomer: GlobalDataAccessor.Instance.DesktopSession.DescribeItemContext = CurrentContext.NEW; ShowForm lookupCustBlk = CommonAppBlocks.Instance.CreateLookupCustomerShowBlock(this.parentForm, this.lookupCustFormNavAction); if (!lookupCustBlk.execute()) { throw new ApplicationException("Cannot execute LookupCustomer block"); } break; case PurchaseFlowState.LookupCustomerResults: ShowForm lookupCustResBlk = CommonAppBlocks.Instance.CreateLookupCustomerResultsBlock(this.parentForm, this.lookupCustResultsFormNavAction); if (!lookupCustResBlk.execute()) { throw new ApplicationException("Cannot execute LookupCustomerResults block"); } break; case PurchaseFlowState.AddCustomer: if (GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger.Equals(Commons.TriggerTypes.NEWPAWNLOAN, StringComparison.OrdinalIgnoreCase)) { ShowForm manageCustBlk = CommonAppBlocks.Instance.CreateManagePawnApplicationBlock(this.parentForm, this.managePawnAppFormNavAction); if (!manageCustBlk.execute()) { throw new ApplicationException("Cannot execute Manage Pawn Application block"); } } else { ShowForm createCustBlk = CommonAppBlocks.Instance.CreateCreateCustomerBlock(this.parentForm, this.createCustomerFormNavAction); if (!createCustBlk.execute()) { throw new ApplicationException("Cannot execute CreateCustomer block"); } } break; case PurchaseFlowState.ExistingCustomer: ShowForm existCustBlk = CommonAppBlocks.Instance.CreateExistingCustomerBlock(this.parentForm, this.existCustomerFormNavAction); if (!existCustBlk.execute()) { throw new ApplicationException("Cannot execute ExistingCustomer block"); } break; case PurchaseFlowState.ManagePawnApplication: ShowForm managePawnAppBlk = CommonAppBlocks.Instance.CreateManagePawnApplicationBlock(this.parentForm, this.managePawnAppFormNavAction); if (!managePawnAppBlk.execute()) { throw new ApplicationException("Cannot execute ManagePawnApplication block"); } break; case PurchaseFlowState.ViewCustomerInformation: ShowForm viewCustInfoBlk = CommonAppBlocks.Instance.ViewCustomerInfoShowBlock(this.parentForm, this.viewCustInfoFormNavAction); if (!viewCustInfoBlk.execute()) { throw new ApplicationException("Cannot execute View Customer Information block"); } break; case PurchaseFlowState.ViewReadOnlyCustomerInformation: ShowForm viewCustInfoReadOnlyBlk = CommonAppBlocks.Instance.ViewCustomerInfoShowBlock(this.parentForm, this.viewCustInfoFormNavAction); if (!viewCustInfoReadOnlyBlk.execute()) { throw new ApplicationException("Cannot execute View customer information Read Only block"); } ((ViewCustomerInformation)viewCustInfoReadOnlyBlk.ClassForm).ShowReadOnly = true; break; case PurchaseFlowState.InvokeMMPIChildFlow: //Initiate the child workflow if (GlobalDataAccessor.Instance.DesktopSession.ActivePurchase == null) { GlobalDataAccessor.Instance.DesktopSession.Purchases.Add(new PurchaseVO()); GlobalDataAccessor.Instance.DesktopSession.DescribeItemPawnItemIndex = -1; } GlobalDataAccessor.Instance.DesktopSession.AppController.invokeWorkflow(MMPIFUNCTIONALITYNAME, this.parentForm, this.endStateNotifier, this); break; case PurchaseFlowState.CancelFlow: if (this.endStateNotifier != null) { this.endStateNotifier.execute(); } break; case PurchaseFlowState.ExitFlow: break; default: throw new ApplicationException("Invalid customer purchase flow state"); } return(true); }