예제 #1
0
        public void Initialize(string reportName, bool landscape, Margins margins)
        {
            List <Control> listRemove = new List <Control>();

            msgr  = new WindowsMessager();
            lgr   = new SQLLogger(msgr, reportName, Environment.UserName);
            cn    = new SqlConnection("SIS", "Sarah", msgr, lgr);
            panel = (Panel)this.Controls["pnlReport"];
            reportViewer.SetPageSettings(new PageSettings()
            {
                Landscape = landscape, Margins = margins
            });

            //if (panel.Controls != null)
            //{
            //    foreach (Control ctrl in panel.Controls)
            //        if (ctrl.Name != "reportViewer") listRemove.Add(ctrl);

            //    foreach (Control ctrl in listRemove)
            //        panel.Controls.Remove(ctrl);
            //}

            reportViewer.Visible = true;

            reportDataSource.Name = "DataSet1";
        }
예제 #2
0
 public BaseReport(string reportName, bool landscape, Margins margins, Control _parent = null)
 {
     InitializeComponent();
     this.Text = reportName;
     parent    = _parent;
     msgr      = new WindowsMessager();
     lgr       = new SQLLogger(msgr, reportName, Environment.UserName);
     cn        = new SqlConnection("SIS", "Sarah", msgr, lgr);
     reportViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
     reportViewer.LocalReport.DataSources.Add(reportDataSource);
     reportViewer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
     Initialize(reportName, landscape, margins);
     AddControls();
     CreateEventHandlers();
 }
예제 #3
0
 public static void Reconfig()
 {
     // Create shared system log
     Logger mainlog = Logger.CreateLogger(MAINLOG, PATH_LOG, LOG_NAME, Logger.GetSeverityByString(LOG_LEVEL));
     Logger sqllog  = SQLLogger.CreateLogger(SQLLOG, PATH_SQLLOG, SQLLOG_NAME, SQLLogger.GetSeverityByString(SQLLOG_LEVEL));
 }
예제 #4
0
        public void HandleException(Exception exception)
        {
            // Don't bother us wth debug exceptions (eg. those running on localhost)
            if (Settings.IgnoreDebugErrors)
            {
                if (Debugger.IsAttached)
                {
                    return;
                }

                if (Settings.IsWebApp)
                {
                    string host = HttpContext.Current.Request.Url.Host.ToLower();
                    if (host == "localhost" || host == "127.0.0.1")
                    {
                        return;
                    }
                }
            }

            // Turn the exception into an informative string
            try {
                Exception     = ExceptionToString(exception);
                ExceptionType = exception.GetType().FullName;

                // Ignore root exceptions
                if (ExceptionType == Settings.RootException || ExceptionType == Settings.RootWsException)
                {
                    if (null != exception.InnerException)
                    {
                        ExceptionType = exception.InnerException.GetType().FullName;
                    }
                }
            }
            catch (Exception ex) {
                Exception = String.Format("Error '{0}' while generating exception string", ex.Message);
            }

            // We are going to ignore System.Web.HttpException errors. Not necessarily the best thing, but
            // for now it will work.
            if (Settings.IgnoreHttpErrors && ExceptionType == Settings.HttpException)
            {
                return;
            }

            // Some exceptions should be ignored: ones that match this regex
            // Note that we are using the entire full-text string of the exception to test regex against
            // so any part of the text can match.
            if (!string.IsNullOrEmpty(Settings.IgnoreRegExp))
            {
                if (Regex.IsMatch(Exception, Settings.IgnoreRegExp, RegexOptions.IgnoreCase))
                {
                    return;
                }
            }

            // Log this error to various locations
            try {
                // Event logging takes < 100ms
                if (Settings.LogToEventLog)
                {
                    ExceptionToEventLog();
                }

                // textfile logging takes < 50ms
                if (Settings.LogToFile)
                {
                    ExceptionToFile();
                }

                // Email logging takes under 1 second
                if (Settings.LogToEmail)
                {
                    ExceptionToEmail();
                }

                //Log exception to JBSAppMonitor DB
                if (Settings.LogToSQL)
                {
                    SQLLogger.ExceptionToSQL(Exception, ExceptionType, new SQLLoggerConfiguration {
                        ConnectionString = Settings.SQLConnectionString,
                        ApplicationId    = Settings.ApplicationID,
                        LocationId       = Settings.LocationID,
                        ReportedBy       = Settings.ReportedBy,
                        SystemId         = Settings.SystemID
                    });
                }
            }
            catch {
                // Absorb the exception
                // Execution stops.
            }
        }