private void configApplication() { try { //Create event log and database trace listeners, and log application as started try { ArgixTrace.AddListener(new DBTraceListener((LogLevel)App.Config.TraceLevel, App.Mediator, App.USP_TRACE, App.EventLogName)); } catch { ArgixTrace.AddListener(new DBTraceListener(LogLevel.Debug, App.Mediator, App.USP_TRACE, App.EventLogName)); ArgixTrace.WriteLine(new TraceMessage("Log level not found; setting log levels to Debug.", App.EventLogName, LogLevel.Warning, "Log Level")); } ArgixTrace.WriteLine(new TraceMessage(App.Version, App.EventLogName, LogLevel.Information, "App Started")); //Create business objects with configuration values App.Mediator.DataStatusUpdate += new DataStatusHandler(OnDataStatusUpdate); EnterpriseFactory.Mediator = App.Mediator; EnterpriseFactory.RefreshCache(); FinanceFactory.Mediator = App.Mediator; FinanceFactory.RefreshCache(); DriverRatingFactory.Mediator = App.Mediator; this.stbMain.SetTerminalPanel(EnterpriseFactory.LocalTerminal.TerminalID.ToString(), EnterpriseFactory.LocalTerminal.Description); bool createError = App.Config.ReadOnly; } catch (Exception ex) { throw new ApplicationException("Configuration Failure", ex); } }
public void RefreshCache() { //Refresh cached data try { //Validate operator state if (!this.mOperatorWorking) { throw new ApplicationException("Station Operator not started for work; call StartWork() before RefreshCache()."); } //Refresh all factory caches SortedItem.ErrorLabelTemplate = SortFactory.CreateOBLabelTemplate(this.mErrorLabelNumber, this.Station.PrinterType); EnterpriseFactory.RefreshCache(); FreightFactory.RefreshCache(); SortFactory.RefreshCache(); } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while refreshing the factory caches.", ex); } }
private void OnMenuClick(object sender, System.EventArgs e) { //Event handler for menu selection Issue issue = null; try { ToolStripDropDownItem menu = (ToolStripDropDownItem)sender; switch (menu.Text) { case MNU_NEW: issue = CRGFactory.GetIssue(0); dlgIssue dlg = new dlgIssue(issue); dlg.Font = this.Font; if (dlg.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; if (issue.Save()) { for (int i = 0; i < this.grdIssues.Rows.Count; i++) { int id = Convert.ToInt32(this.grdIssues.Rows[i].Cells["ID"].Value); if (id == issue.ID) { this.grdIssues.Rows[i].Selected = true; this.grdIssues.DisplayLayout.Bands[0].Columns["LastActionCreated"].SortIndicator = SortIndicator.Descending; OnGridSelectionChanged(this.grdIssues, null); break; } } } } break; case MNU_OPEN: break; case MNU_SAVE: break; case MNU_SAVEAS: SaveFileDialog dlgSave = new SaveFileDialog(); dlgSave.AddExtension = true; dlgSave.Filter = "Export Files (*.xml) | *.xml | Excel Files (*.xls) | *.xls"; dlgSave.FilterIndex = 0; dlgSave.Title = "Save Issues As..."; dlgSave.FileName = ""; dlgSave.OverwritePrompt = true; if (dlgSave.ShowDialog(this) == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); if (dlgSave.FileName.EndsWith("xls")) { new Argix.ExcelFormat().Transform(this.mIssues, dlgSave.FileName); } else { this.mIssues.WriteXml(dlgSave.FileName, XmlWriteMode.WriteSchema); } } break; case MNU_SETUP: UltraGridPrinter.PageSettings(); break; case MNU_PRINT: UltraGridPrinter.Print(this.grdIssues, this.grdIssues.Text, true); break; case MNU_PREVIEW: UltraGridPrinter.PrintPreview(this.grdIssues, this.grdIssues.Text); break; case MNU_REFRESH: this.Cursor = Cursors.WaitCursor; this.mGridSvcIssues.CaptureState("ID"); switch (this.cboView.Text) { case "Search Results": break; case "Issue History": this.mIssueHistory.Clear(); this.mIssueHistory.Merge(CRGFactory.IssueHistory(this.mIssueH)); break; case "Draft Issues": break; default: DataSet ds = CRGFactory.GetIssues(); lock (this.mIssues) { this.mIssues.Clear(); this.mIssues.Merge(ds); } postIssueUpdates(); break; } this.mGridSvcIssues.RestoreState(); break; case MNU_REFRESHCACHE: EnterpriseFactory.RefreshCache(); CRGFactory.RefreshCache(); break; case MNU_AUTOREFRESHON: this.mnuCtxAutoRefreshOn.Checked = !this.mnuCtxAutoRefreshOn.Checked; if (this.mnuCtxAutoRefreshOn.Checked) { StartAuto(); } else { StopAuto(); } break; case MNU_CONTACTS: winContacts winC = new winContacts(); winC.Font = this.Font; winC.ShowDialog(); break; case MNU_PROPERTIES: break; } } catch (Exception ex) { reportError(ex); } finally { setUserServices(); this.Cursor = Cursors.Default; } }