/// <summary> /// Specifies the current staff has access to the passed in module. /// </summary> /// <param name="module">The module the staff has permission /// to.</param> public void AddModule(EliteModule module) { if (!m_modulesAndFeatures.ContainsKey(module)) { m_modulesAndFeatures.Add(module, new List <int>()); } }
/// <summary> /// Retrieves a list of sessions /// </summary> /// <param name="sender">The source of the request</param> /// <param name="e">The argument passed in</param> private void DoRequestSessions(object sender, DoWorkEventArgs e) { EliteModule.SetThreadCulture(Parent.Settings); DateTime date = (DateTime)e.Argument; e.Result = SendRequestSessions(date); }
/// <summary> /// Specifies the current staff has access to the passed in module /// feature. /// </summary> /// <param name="module">The module the feature belongs to.</param> /// <param name="moduleFeatureId">The module feature the staff has /// permission to.</param> public void AddModuleFeature(EliteModule module, int moduleFeatureId) { // Add the module, if needed. AddModule(module); if (!m_modulesAndFeatures[module].Contains(moduleFeatureId)) { m_modulesAndFeatures[module].Add(moduleFeatureId); } }
/// <summary> /// Checks to see if the current staff has permission to the specified /// module feature. /// </summary> /// <param name="module">The module the feature belongs to.</param> /// <param name="moduleFeatureId">The id of the feature to /// check.</param> /// <returns>true if the user has access to the feature; otherwise /// false.</returns> public bool CheckModuleFeature(EliteModule module, int moduleFeatureId) { if (!CheckModule(module)) { return(false); } else { return(m_modulesAndFeatures[module].Contains(moduleFeatureId)); } }
/// <summary> /// Saves the session summary /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The work argument passed in.</param> private void DoRequestSetSummary(object sender, DoWorkEventArgs e) { EliteModule.SetThreadCulture(Parent.Settings); SetSessionSummary msg = new SetSessionSummary((Summary)e.Argument); msg.Send(); if (msg.ReturnCode != ServerReturnCode.Success) { throw new SessionSummaryException(ServerErrorTranslator.GetReturnCodeMessage(msg.ReturnCode)); } }
/// <summary> /// Loads the SessionSummary's settings from the server. /// </summary> /// <param name="operatorId">The id of the operator to use in the /// settings messages.</param> /// <param name="machineId">The id of the machine to use in the /// settings messages.</param> /// <returns>true if success; otherwise false.</returns> private bool LoadSettings(int operatorId, int machineId) { try { EliteModule.GetModuleSettings(Settings, machineId, operatorId, SettingCategory.GlobalSystemSettings); } catch (Exception ex) { MessageWindow.Show(string.Format(CultureInfo.CurrentCulture, Resources.GetSettingsFailed, ex.Message), Resources.SessionSummaryName, MessageWindowType.Close); return(false); } return(true); }
/// <summary> /// Intializes the an instance of a SummaryController class. /// </summary> /// <param name="parent">The parent session summary controller.</param> public SummaryController(ISessionSummaryController parent) { if (parent == null) { throw new ArgumentNullException("parent"); } Parent = parent; IsBusy = false; // Get a default session list m_sessionList = new Dictionary <DateTime, IList <short> >(); Parent.LoadingMessage(Resources.LoadingSessions); GamingDate = EliteModule.GetGamingDate(); SendRequestSessions(GamingDate); }
/// <summary> /// Requests any pending increases for the session on the specified date to be applied. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The work argument passed in.</param> private void DoTriggerAcc2Increases(object sender, DoWorkEventArgs e) { EliteModule.SetThreadCulture(Parent.Settings); // Unbox the arguments. ArrayList args = (ArrayList)e.Argument; DateTime date = (DateTime)args[0]; short session = (short)args[1]; var spMsg = new GetSessionPlayedsMessage(date, date); spMsg.Send(); if (spMsg.ReturnCode != ServerReturnCode.Success) { throw new SessionSummaryException(ServerErrorTranslator.GetReturnCodeMessage(spMsg.ReturnCode)); } var sps = spMsg.Sessions; Games.Bingo.Model.SessionPlayed theSP = null; foreach (var sp in sps) { if (!sp.Overridden && sp.GamingSession == session) { theSP = sp; break; } } if (theSP == null) { throw new SessionSummaryException("Session identifier not found"); } var accMsg = new TriggerAcc2AutoIncreasesRequest(date, theSP.SessionPlayedID, false, true); accMsg.Send(); if (accMsg.ReturnCode != ServerReturnCode.Success) { throw new SessionSummaryException(ServerErrorTranslator.GetReturnCodeMessage(accMsg.ReturnCode)); } e.Result = accMsg.IncreaseCount; }
/// <summary> /// Loads the current staff member and a list of all staff. /// </summary> /// <param name="staffId">The Id of the current staff member logged in.</param> /// <returns>True if successful; otherwise false.</returns> private bool LoadStaff(int staffId) { LoadingForm.Status = Resources.LoadingStaff; try { List <Staff> staff = EliteModule.GetStaff(staffId, false, true); if (staff == null || staff.Count == 0) { throw new SessionSummaryException(Resources.LoadingStaffFailedCurrentNotFound); } else { StaffMember = staff[0]; } staff = EliteModule.GetStaff(0, true, false); if (staff == null || staff.Count == 0) { throw new SessionSummaryException(Resources.LoadingStaffFailedNoStaffFound); } else { // The default is current user (if they are in the list). List <Staff> tempStaffList = (from staffMember in staff where staffMember.Id != Staff.AutomatedSale && staffMember.Id != Staff.GameTechEmployee select staffMember).ToList(); staff = tempStaffList; staff.Sort(); m_staffMembers = staff; RaisePropertyChanged("StaffMembers"); } } catch (Exception ex) { Logger.Log("Get staff failed: " + ex.Message, LoggerLevel.Severe); MessageWindow.Show(string.Format(CultureInfo.CurrentCulture, Resources.LoadingStaffFailed, ex.Message), Resources.SessionSummaryName, MessageWindowType.Close); return(false); } return(true); }
/// <summary> /// Retrieves a calculated summary. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The work argument passed in.</param> private void DoRequestCalcdSummary(object sender, DoWorkEventArgs e) { EliteModule.SetThreadCulture(Parent.Settings); // Unbox the arguments. ArrayList args = (ArrayList)e.Argument; DateTime date = (DateTime)args[0]; short session = (short)args[1]; GetCalculatedSessionSummary msgCalcd = new GetCalculatedSessionSummary(date, session); msgCalcd.Send(); if (msgCalcd.ReturnCode != ServerReturnCode.Success) { throw new SessionSummaryException(ServerErrorTranslator.GetReturnCodeMessage(msgCalcd.ReturnCode)); } e.Result = msgCalcd.Summary; }
/// <summary> /// Retrieves a summary /// </summary> /// <param name="sender">The source of the event</param> /// <param name="e">The work argument passed in</param> private void DoRequestSummary(object sender, DoWorkEventArgs e) { EliteModule.SetThreadCulture(Parent.Settings); // Unbox the arguments. ArrayList args = (ArrayList)e.Argument; DateTime date = (DateTime)args[0]; short session = (short)args[1]; GetCalculatedSessionSummary msgCalcd = new GetCalculatedSessionSummary(date, session); msgCalcd.Send(); if (msgCalcd.ReturnCode != ServerReturnCode.Success) { throw new SessionSummaryException(ServerErrorTranslator.GetReturnCodeMessage(msgCalcd.ReturnCode)); } GetSavedSessionSummary msgSaved = new GetSavedSessionSummary(date, session, StaffMembers); msgSaved.Send(); if (msgSaved.ReturnCode == ServerReturnCode.MissingTableEntry) { //swallow this return code there will be not data } else if (msgSaved.ReturnCode != ServerReturnCode.Success) { throw new SessionSummaryException(ServerErrorTranslator.GetReturnCodeMessage(msgSaved.ReturnCode)); } ArrayList results = new ArrayList(); results.Add(msgCalcd.Summary); results.Add(msgSaved.Summary); e.Result = results; }
/// <summary> /// Performs any processing or data setup needed before the module is /// started. /// </summary> /// <param name="showLoadingWindow">Whether the module should display a /// loading or splash screen while performing initialization.</param> /// <param name="isTouchScreen">Whether this module is running on a /// touchscreen-based device.</param> /// <param name="instanceId">The unique identifier of the running /// instance of this module.</param> /// <returns>true if the initialization was successful; otherwise, /// false.</returns> public bool Initialize(bool showLoadingWindow, bool isTouchScreen, int instanceId) { // Check to see if we are already initialized. if (IsInitialized) { return(IsInitialized); } InstanceId = instanceId; // Create a settings object with the default values. Settings = new SessionSummarySettings(); // Start COM interface to EliteMCP. EliteModuleComm modComm = null; int machineId = 0; int staffId = 0; try { modComm = new EliteModuleComm(); machineId = modComm.GetMachineId(); OperatorId = modComm.GetOperatorId(); staffId = modComm.GetStaffId(); } catch (Exception ex) { MessageBoxOptions options = 0; if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft) { options = MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign; } MessageBox.Show(string.Format(CultureInfo.CurrentCulture, Resources.GetDeviceInfoFailed, ex.Message), Resources.SessionSummaryName, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, options); return(IsInitialized); } // Session Summary always runs in windowed mode. Settings.DisplayMode = DisplayMode.Windowed; // Create and show the loading form. LoadingForm = new LoadingForm(Settings.DisplayMode); LoadingForm.ApplicationName = Resources.SessionSummaryName; LoadingForm.Version = EliteModule.GetVersion(Assembly.GetExecutingAssembly()); LoadingForm.Copyright = EliteModule.GetCopyright(Assembly.GetExecutingAssembly()); LoadingForm.Cursor = System.Windows.Forms.Cursors.WaitCursor; if (showLoadingWindow) { LoadingForm.Show(); } LoadingForm.Status = Resources.LoadingMachineInfo; CreateApplication(); if (!LoadSettings(OperatorId, machineId)) { return(IsInitialized); } if (!LoadOperatorData(OperatorId)) { return(IsInitialized); } if (!LoadStaff(staffId)) { return(IsInitialized); } if (!CreateLogger()) { return(IsInitialized); } // Check to see if we only want to display in English. if (Settings.ForceEnglish) { EliteModule.ForceEnglish(); Logger.Log("Forcing English.", LoggerLevel.Configuration); } if (!LoadCurrencies()) { return(IsInitialized); } if (!CreateControllers()) { return(IsInitialized); } if (!CreateReport()) { return(IsInitialized); } LoadingForm.Status = Resources.Starting; if (!CreateWindows()) { return(IsInitialized); } // Have the controller notified when the main window opens. MainWindow.Loaded += MainWindowLoaded; IsInitialized = true; Logger.Log("Session Summary initialized!", LoggerLevel.Debug); return(IsInitialized); }
/// <summary> /// Displays the specified view. /// </summary> /// <param name="view">The view to display.</param> /// <exception cref="System.ArgumentException">view is /// invalid.</exception> public void NavigateTo(SessionSummaryView view, NavigateToArgs e) { switch (view) { case SessionSummaryView.About: AboutWindow aboutWin = new AboutWindow(Settings.UseAcceleration, Resources.SessionSummaryName, EliteModule.GetVersion(Assembly.GetExecutingAssembly()), EliteModule.GetCopyright(Assembly.GetExecutingAssembly()), Resources.ModuleDescription); aboutWin.Owner = MainWindow; CurrentView = aboutWin; aboutWin.ShowDialog(); CurrentView = MainWindow; break; case SessionSummaryView.SessionCosts: { SessionCostsWindow sessionCostWin = new SessionCostsWindow(Settings.UseAcceleration); sessionCostWin.Owner = MainWindow; sessionCostWin.DataContext = new SessionCostsViewModel(SessionCostsController); CurrentView = sessionCostWin; sessionCostWin.ShowDialog(); ((IDisposable)sessionCostWin.DataContext).Dispose(); CurrentView = MainWindow; } break; case SessionSummaryView.SelectSessionCosts: { SelectSessionCostsWindow sessionCostWin = new SelectSessionCostsWindow(Settings.UseAcceleration); sessionCostWin.Owner = MainWindow; sessionCostWin.DataContext = new SelectSessionCostsViewModel(SessionCostsController, (Summary)e.Argument); CurrentView = sessionCostWin; sessionCostWin.ShowDialog(); ((IDisposable)sessionCostWin.DataContext).Dispose(); CurrentView = MainWindow; } break; case SessionSummaryView.Report: { if (m_reportWindow == null) { m_reportWindow = new SessionSummaryReportWindow(); m_reportWindow.Owner = MainWindow; m_reportWindow.Closed += ReportWindowClosed; m_reportWindow.Show(); } m_reportWindow.Focus(); ArrayList args = (ArrayList)e.Argument; DateTime date = (DateTime)args[0]; short session = (short)args[1]; RefreshSessionSummaryReport(date, session); m_reportWindow.DisplayReport(SessionSummaryReport); } break; case SessionSummaryView.ActualCashCalculator: { var calcWin = new ActualCashCalculatorWindow(Settings.UseAcceleration); calcWin.Owner = MainWindow; calcWin.DataContext = new ActualCashCalculatorViewModel(this, (Summary)e.Argument); CurrentView = calcWin; calcWin.ShowDialog(); var disposable = calcWin.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } CurrentView = MainWindow; } break; case SessionSummaryView.SessionBankBreakdown: { var calcWin = new SessionBanksWindow(Settings.UseAcceleration); calcWin.Owner = MainWindow; calcWin.DataContext = new SessionBanksViewModel(this, (List <BasicBankInfo>)e.Argument); CurrentView = calcWin; calcWin.ShowDialog(); var disposable = calcWin.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } CurrentView = MainWindow; } break; default: throw new ArgumentException(); } }
/// <summary> /// Checks to see if the current staff has permission to the /// specified module. /// </summary> /// <param name="module">The module to check.</param> /// <returns>true if the user has access to the module; otherwise /// false.</returns> public bool CheckModule(EliteModule module) { return(m_modulesAndFeatures.ContainsKey(module)); }