Exemple #1
0
 //
 private void btnExport_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         btnExport.IsEnabled = false;
         BMC.CashDeskOperator.CollectionHelper collectionHelper = (isCommonCDOforDeclaration && !string.IsNullOrEmpty(ExchangeConst)) ? new BMC.CashDeskOperator.CollectionHelper(CommonUtilities.SiteConnectionString(ExchangeConst)) : new BMC.CashDeskOperator.CollectionHelper();
         collectionHelper.InsertIntoExportHistory(_BatchID);
         MessageBox.ShowBox("MessageID204");
     }
     catch (Exception ex)
     {
         LogError("btnExport_Click", ex);
     }
     finally
     {
         btnExport.IsEnabled = true;
     }
 }
        /// <summary>
        /// Common Method to Show Hide Controls based on SlotMachine Status
        /// </summary>
        /// <param name="eStatus"></param>
        private void ShowHideControls(SlotMachineStatus eStatus)
        {


            //Hide All Controls by default and then Toggle Visibility based on the Slot Status
            rbEvents.Visibility = Visibility.Collapsed;
            rbFieldService.Visibility = Visibility.Collapsed;
            rbHandpay.Visibility = Visibility.Collapsed;
            rbMachineMaintenance.Visibility = Visibility.Collapsed;
            rbMachineMeters.Visibility = Visibility.Collapsed;
            rbPlayerClub.Visibility = Visibility.Collapsed;
            rbRemoveMachine.Visibility = Visibility.Collapsed;
            rbReInstateMachine.Visibility = Visibility.Collapsed;
            rbSyncTicketExpire.Visibility = Visibility.Collapsed;
            rbCurrentMeters.Visibility = Visibility.Collapsed;
            if ((Settings.AllowMultipleDrops || Settings.Allow_Machine_Removal) && Settings.IsFinalDropRequiredForRemoval)
            {
                rbRemoveMachine.Visibility = Visibility.Visible;
            }
            if (!Settings.IsFinalDropRequiredForRemoval && (eStatus != SlotMachineStatus.VLTunderMaintenance
                                                                && eStatus != SlotMachineStatus.VLTunderUnauthorizedMaintenance))
            {
                rbRemoveMachine.Visibility = HasAccess(PositionDetailsScreen.RemoveMachine) ? Visibility.Visible : Visibility.Collapsed;
                rbReInstateMachine.Visibility = HasAccess(PositionDetailsScreen.ReinstateMachine) ? Visibility.Visible : Visibility.Collapsed;
                rbSyncTicketExpire.Visibility = Visibility.Collapsed;
                rbCurrentMeters.Visibility = Visibility.Collapsed;
            }

            switch (eStatus)
            {
                case SlotMachineStatus.CardedHandPay:
                case SlotMachineStatus.CardedPlay:
                case SlotMachineStatus.EmpCardedPlay:
                case SlotMachineStatus.NonCardedHandPay:
                case SlotMachineStatus.NonCardedPlay:
                case SlotMachineStatus.MachineInPlay:
                case SlotMachineStatus.NotInPlay:
                case SlotMachineStatus.CommsDown:
                case SlotMachineStatus.GameDown:
                    rbHandpay.Visibility = HasAccess(PositionDetailsScreen.Handpay) ? Visibility.Visible : Visibility.Collapsed;
                    rbPlayerClub.Visibility = HasAccess(PositionDetailsScreen.PlayerClub) ? Visibility.Visible : Visibility.Collapsed;
                    rbEvents.Visibility = HasAccess(PositionDetailsScreen.Events) ? Visibility.Visible : Visibility.Collapsed;
                    rbFieldService.Visibility = HasAccess(PositionDetailsScreen.FieldService) ? Visibility.Visible : Visibility.Collapsed;
                    rbMachineMeters.Visibility = HasAccess(PositionDetailsScreen.MachineMeters) ? Visibility.Visible : Visibility.Collapsed;
                    rbSyncTicketExpire.Visibility = HasAccess(PositionDetailsScreen.SyncTicketExpire) ? Visibility.Visible : Visibility.Collapsed;
                    rbCurrentMeters.Visibility = HasAccess(PositionDetailsScreen.CurrentMeters) ? Visibility.Visible : Visibility.Collapsed;

                    if (!isScreenLoaded)
                    {
                        if (rbHandpay.IsVisible)
                        {
                            rbHandpay.IsChecked = true;
                            LoadScreen(PositionDetailsScreen.Handpay);
                        }
                        else if (rbPlayerClub.IsVisible)
                        {
                            rbPlayerClub.IsChecked = true;
                            LoadScreen(PositionDetailsScreen.PlayerClub);
                        }
                        else if (rbEvents.IsVisible)
                        {
                            rbEvents.IsChecked = true;
                            LoadScreen(PositionDetailsScreen.Events);
                        }
                        else if (rbFieldService.IsVisible)
                        {
                            rbFieldService.IsChecked = true;
                            LoadScreen(PositionDetailsScreen.FieldService);
                        }
                        else if (rbMachineMeters.IsVisible)
                        {
                            rbMachineMeters.IsChecked = true;
                            LoadScreen(PositionDetailsScreen.MachineMeters);
                        }
                        else if (rbCurrentMeters.IsVisible)
                        {
                            rbCurrentMeters.IsChecked = true;
                            LoadScreen(PositionDetailsScreen.CurrentMeters);
                        }
                        else if (rbMachineMaintenance.IsVisible)
                        {
                            rbMachineMaintenance.IsChecked = true;
                            LoadScreen(PositionDetailsScreen.MachineMaintenance);
                        }
                    }
                    else
                    {
                        if (rbHandpay.IsChecked.SafeValue())
                        {
                            LoadScreen(PositionDetailsScreen.Handpay, true);
                        }
                    }

                    break;

                case SlotMachineStatus.FloatCollection:
                    CollectionHelper CollectionHelper = new CollectionHelper();
                    pnlContent.Children.Clear();
                    if (!CollectionHelper.HasUndeclaredCollecion(_SlotMachine.InstallationNo))
                    {
                        

                        rbRemoveMachine.Visibility = HasAccess(PositionDetailsScreen.RemoveMachine) ? Visibility.Visible : Visibility.Collapsed;

                        var installationDataContext =
                            new InstallationDataContext(oCommonUtilities.CreateInstance().GetConnectionString());
                        IList<FloorStatusData> barPositions;
                        barPositions = installationDataContext.GetSlotStatus("", _SlotMachine.InstallationNo);
                        if (barPositions.Count > 0)
                        {
                            var position = barPositions[0];
                            if (position.FinalCollectionStatus == 1)
                            {
                                rbReInstateMachine.Visibility = Visibility.Collapsed;
                            }
                            else
                            {
                                rbReInstateMachine.Visibility = HasAccess(PositionDetailsScreen.ReinstateMachine) ? Visibility.Visible : Visibility.Collapsed;
                            }

                        }
                    }
                    break;

                case SlotMachineStatus.EmptyPosition:
                //case SlotMachineStatus.GameInstallationAAMSPending:
                //case SlotMachineStatus.VLTInstallationAAMSPending:
                case SlotMachineStatus.InstallationCompletedNonMetered:
                    if (Exit != null)
                    {
                        Exit.Invoke(this, new CancelEventArgs());
                    }
                    break;

                case SlotMachineStatus.GoldClubCardedPlay:
                    break;

                //case SlotMachineStatus.VLTunderMaintenance:
                //case SlotMachineStatus.VLTunderUnauthorizedMaintenance:
                //    rbMachineMaintenance.Visibility = HasAccess(PositionDetailsScreen.MachineMaintenance) ? Visibility.Visible : Visibility.Collapsed;
                //    rbMachineMaintenance.IsChecked = rbMachineMaintenance.IsVisible;
                //    isScreenLoaded = true;
                //    if (!isScreenLoaded || isFirstTime)
                //    {
                //        LoadScreen(PositionDetailsScreen.MachineMaintenance);
                //        isFirstTime = false;
                //    }
                //    break;

                default:
                    break;
            }



        }
        private void RemoveMachine_Click(object sender, RoutedEventArgs e)
        {
            LogManager.WriteLog("RemoveMachine_Click", LogManager.enumLogLevel.Info);

            int machineStatusFlag = 0;
            string siteCode = string.Empty;
            bool ShowRemoveConfirmation = true;
            bool canProcess = false;

            try
            {
                Cursor = System.Windows.Input.Cursors.Wait;

                // For Transit Machine - Italy Requirement
                if (Settings.RegulatoryEnabled && Settings.RegulatoryType == "AAMS" && ucSlotMachine.Status != SlotMachineStatus.GameInstallationAAMSPending && ucSlotMachine.Status != SlotMachineStatus.VLTInstallationAAMSPending)
                {
                    if (MessageBox.ShowBox("MessageID344", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        while (!canProcess)
                        {
                            ActiveSites objActiveSites = new ActiveSites();

                            try
                            {
                                objActiveSites.ShowDialogEx(this);

                                if (objActiveSites.DialogResult == true)
                                {
                                    siteCode = objActiveSites.TransiteSiteCode;
                                    machineStatusFlag = INTRANSITEASSET;
                                    ShowRemoveConfirmation = false;

                                    if (siteCode == string.Empty | siteCode == "Select")
                                    {
                                        MessageBox.ShowBox("MessageID340", BMC_Icon.Information);
                                    }
                                    else
                                    {
                                        canProcess = true;
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }
                            catch (Exception ex)
                            {
                                ExceptionManager.Publish(ex);
                                return;
                            }
                            finally
                            {
                                if (objActiveSites != null)
                                    objActiveSites = null;
                            }
                        }
                    }
                    else
                    {
                        ShowRemoveConfirmation = true;
                    }
                }

                //Confirmation
                if (ShowRemoveConfirmation)
                {
                    if (MessageBox.ShowBox("MessageID4", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                        return;
                }
                int InstallationNo = _SlotMachine.InstallationNo;
                CollectionHelper CollectionHelper = new CollectionHelper();

                #region Machine Removal

                InstallationDataContext objRemoveContext =
                                        new InstallationDataContext(oCommonUtilities.CreateInstance().GetConnectionString());
                int nDisMachine = 0;

                //When FinalCollection Status is set machine must be already disabled.
                if (_SlotMachine.FinalCollectionStatus == 0)
                    foreach (var IP in objRemoveContext.GetDisableMachine(InstallationNo))
                    {
                        nDisMachine = IP.DisMachine;
                    }


                EnrollmentErrorCodes ErrorCode = EnrollmentBusinessObject.CreateInstance().RemoveMachine(InstallationNo, machineStatusFlag, siteCode, nDisMachine);
                switch (ErrorCode)
                {
                    case EnrollmentErrorCodes.DatabaseError:
                        {
                            MessageBox.ShowBox("MessageID206");
                            Audit_Error("Database Error");
                            break;
                        }
                    case EnrollmentErrorCodes.EnterpriseWebServiceCommunicationFailure:
                        {
                            MessageBox.ShowBox("MessageID207");
                            Audit_Error("Enterprise WebService Communication Failure");
                            break;
                        }
                    case EnrollmentErrorCodes.RemoveFromPollingListFailure:
                        {
                            MessageBox.ShowBox("MessageID208");
                            Audit_Error("Unable to remove from Polling list");
                            break;
                        }
                    case EnrollmentErrorCodes.ExchangeHostServiceNotRunning:
                        {
                            Audit_Error("Unable to remove from Polling list: Timeout occured");
                            if (MessageBox.ShowBox("MessageID359", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.No)
                                return;
                            //Calling Remove Machine with Disable Machine command as false, Since first attempt to Disable Failed.
                            ErrorCode = EnrollmentBusinessObject.CreateInstance().RemoveMachine(InstallationNo, machineStatusFlag, siteCode, 0);

                            switch (ErrorCode)
                            {
                                case EnrollmentErrorCodes.DatabaseError:
                                    {
                                        MessageBox.ShowBox("MessageID206");
                                        Audit_Error("Database Error");
                                        break;
                                    }
                                case EnrollmentErrorCodes.EnterpriseWebServiceCommunicationFailure:
                                    {
                                        MessageBox.ShowBox("MessageID207");
                                        Audit_Error("Enterprise WebService Communication Failure");
                                        break;
                                    }
                                case EnrollmentErrorCodes.RemoveFromPollingListFailure:
                                    {
                                        MessageBox.ShowBox("MessageID208");
                                        Audit_Error("Unable to remove from Polling list");
                                        break;
                                    }
                                case EnrollmentErrorCodes.ExchangeHostServiceNotRunning:
                                    {
                                        Audit_Error("Unable to remove from Polling list: Timeout occured");
                                        MessageBox.ShowBox("MessageID360", BMC_Icon.Error);
                                        break;
                                    }
                                case EnrollmentErrorCodes.Success:
                                    MessageBox.ShowBox("MessageID209");

                                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                    {

                                        AuditModuleName = ModuleName.RemoveMachine,
                                        Audit_Screen_Name = "Position Details|Remove Machine",
                                        Audit_Desc = "Machine Removed from Position: "
                                                     + Convert.ToInt32(sBarPosName).ToString(),
                                        AuditOperationType = OperationType.MODIFY,
                                        Audit_Slot = lblAsset.Text,
                                        Audit_Field = "Position",
                                        Audit_Old_Vl = Convert.ToInt32(sBarPosName).ToString()
                                    });
                                    break;


                            }
                            return;

                            break;
                        }
                    case EnrollmentErrorCodes.Success:
                        MessageBox.ShowBox("MessageID209");

                        if (machineStatusFlag != 18)
                        {
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.RemoveMachine,
                                Audit_Screen_Name = "Position Details|Remove Machine",
                                Audit_Desc = "Machine Removed from Position: "
                                             + Convert.ToInt32(sBarPosName).ToString(),
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Slot = _SlotMachine.AssetNumber,
                                Audit_Field = "Position",
                                Audit_Old_Vl = Convert.ToInt32(sBarPosName).ToString()
                            });
                        }
                        else
                        {
                            AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                            {

                                AuditModuleName = ModuleName.TransitMachine,
                                Audit_Screen_Name = "Position Details|Transit Machine",
                                Audit_Desc = string.Format("{0} - {1}", "Machine is in Transit for Site", siteCode),
                                AuditOperationType = OperationType.MODIFY,
                                Audit_Slot = _SlotMachine.AssetNumber,
                                Audit_Field = "Asset",
                                Audit_Old_Vl = string.Format("{0}|{1}", Settings.SiteCode, Convert.ToInt32(sBarPosName).ToString())
                            });
                        }

                        if (Exit != null)
                        {
                            Timer.Stop();
                            Exit.Invoke(this, new CancelEventArgs());
                        }
                        break;
                }
                #endregion
            }
            finally
            {
                Cursor = System.Windows.Input.Cursors.Arrow;
            }
        }